mirror of
https://github.com/fradelg/docker-mysql-cron-backup.git
synced 2024-11-01 08:31:45 +01:00
21 lines
538 B
Bash
Executable file
21 lines
538 B
Bash
Executable file
#!/bin/bash
|
|
touch /mysql_backup.log
|
|
tail -F /mysql_backup.log &
|
|
|
|
if [ -n "${INIT_BACKUP}" ]; then
|
|
echo "=> Create a backup on the startup"
|
|
/backup.sh
|
|
elif [ -n "${INIT_RESTORE_LATEST}" ]; then
|
|
echo "=> Restore latest backup"
|
|
until nc -z $MYSQL_HOST $MYSQL_PORT
|
|
do
|
|
echo "waiting database container..."
|
|
sleep 1
|
|
done
|
|
ls -d -1 /backup/* | tail -1 | xargs /restore.sh
|
|
fi
|
|
|
|
echo "${CRON_TIME} /backup.sh >> /mysql_backup.log 2>&1" > /crontab.conf
|
|
crontab /crontab.conf
|
|
echo "=> Running cron task manager"
|
|
exec crond -f
|