Changed find regex to explain date-format

This commit is contained in:
Giuseppe Nardiello 2023-01-17 22:57:09 +01:00
parent 400bb8c95e
commit 8eb4379305

5
run.sh
View file

@ -11,8 +11,9 @@ elif [ -n "${INIT_RESTORE_LATEST}" ]; then
echo "waiting database container..."
sleep 1
done
# 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
# 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
echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /tmp/crontab.conf