levente@testsrv:~$ crontab -e
# ....
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
15 2 * * * mysqldump -u mysqluser -pmysqlpassword db_name | gzip > /var/backups/mysql/db_name_`date '+\%Y\%m\%d-\%H\%M\%S'`.sql.gz
20 2 * * * find /var/backups/mysql/db_name* -mtime +30 -exec rm {} \;
If you want to run the MySQL backup script directly at the shell, you have to remove the backslash characters before the % because these are escaped in cron.
levente@testsrv:~$ mysqldump -u mysqluser -pmysqlpassword db_name | gzip > /var/backups/mysql/db_name_`date '+%Y%m%d-%H%M%S'`.sql.gz
No comments:
Post a Comment