add no litestream option

This commit is contained in:
2021-09-17 11:54:53 -04:00
parent 689d978d32
commit fd4a05207f

View File

@@ -28,6 +28,7 @@ if [ "$NOMAD_TASK_NAME" == "init" ]; then
rm -rf /config/*.db*
rm -rf /config/database.sqlite
if [[ -f /local/litestream.yml ]]; then
echo "Starting DB Restore"
if /usr/local/bin/litestream restore -config /local/litestream.yml /config/${DB_NAME}; then
@@ -52,7 +53,25 @@ if [ "$NOMAD_TASK_NAME" == "init" ]; then
unzip -o $latest -d /config
fi
fi
else
echo "NO LITESTREAM DETECTED - trying to restore backup"
unset -v latest
if [ -d "/configbackup/Backups/scheduled" ]; then
for file in "/configbackup/Backups/scheduled"/*; do
[[ $file -nt $latest ]] && latest=$file
done
fi
if [ -d "/configbackup/Backups/manual" ]; then
for file in "/configbackup/Backups/manual"/*; do
[[ $file -nt $latest ]] && latest=$file
done
fi
if [ -z "$latest" ]; then
echo "No Backups found";
else
echo "Restoring $latest"
unzip -o $latest -d /config
fi
chown ${PUID:-1000}:${PGID:-1000} /config/*.db*