Merge pull request #92 from g-nardiello/patch-restore-latest-sort

[Bugfix] RESTORE_LATEST script sorted by backup date
This commit is contained in:
Fco. Javier Delgado del Hoyo 2023-01-19 19:29:10 +01:00 committed by GitHub
commit 8d2e012667
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

4
run.sh
View file

@ -11,7 +11,9 @@ elif [ -n "${INIT_RESTORE_LATEST}" ]; then
echo "waiting database container..." echo "waiting database container..."
sleep 1 sleep 1
done done
find /backup -maxdepth 1 -name '*.sql.gz' | tail -1 | xargs /restore.sh # Needed to exclude the 'latest.<database>.sql.gz' file, consider only filenames starting with number
# Only data-tagged backups, eg. '202212250457.database.sql.gz', must be trapped by the regex
find /backup -maxdepth 1 -name '[0-9]*.*.sql.gz' | sort | tail -1 | xargs /restore.sh
fi fi
echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf