adding auto restore of DB

This commit is contained in:
2021-09-15 09:07:17 -04:00
parent ebd28607a8
commit a7c309df81
2 changed files with 18 additions and 2 deletions

View File

@@ -30,7 +30,23 @@ if [ "$NOMAD_TASK_NAME" == "init" ]; then
echo "Starting DB Restore"
/usr/local/bin/litestream restore -config /local/litestream.yml /config/${DB_NAME}
if /usr/local/bin/litestream restore -config /local/litestream.yml /config/${DB_NAME}; then
echo "Restore of ${DB_NAME} Succeeded: "
else
echo "Restore of ${DB_NAME} failed"
unset -v latest
for file in "/configbackup/Backups/scheduled"/*; do
[[ $file -nt $latest ]] && latest=$file
done
for file in "/configbackup/Backups/manual"/*; do
[[ $file -nt $latest ]] && latest=$file
done
echo "Restoring $latest"
unzip -o $latest -d /config
fi
chown ${PUID:-1000}:${PGID:-1000} /config/*.db*
if [ -n "$DBCHMOD" ]; then
chmod ${DBCHMOD} /config/${DB_NAME}.db;