From 400bb8c95e26cdd68340d89d60aacaad7b11a90b Mon Sep 17 00:00:00 2001 From: "g.nardiello" Date: Thu, 5 Jan 2023 11:47:54 +0100 Subject: [PATCH] Added sort algorithm to RESTORE_LATEST script --- run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 95f8009..a5151f4 100755 --- a/run.sh +++ b/run.sh @@ -11,7 +11,8 @@ elif [ -n "${INIT_RESTORE_LATEST}" ]; then echo "waiting database container..." sleep 1 done - find /backup -maxdepth 1 -name '*.sql.gz' | tail -1 | xargs /restore.sh + # The [^l] is needed to exclude the latest backup file, and sort only data-tagged backups + find /backup -maxdepth 1 -name '[^l]*.sql.gz' | sort | tail -1 | xargs /restore.sh fi echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf