Return to Snippet

Revision: 45147
at April 26, 2011 06:16 by nikefido

Initial Code
/usr/bin/mysqldump --user=DB_USER --password='DB_PASSWORD'  --databases DB_NAME | gzip > /path/to/backup/DB_NAME-`date +%Y%m%d%H%M`.sql.gz
find /path/to/backup -name "*.gz" -mtime +60 -exec /bin/rm {} \;

Initial URL

Initial Description
Creates a daily backup and deletes any backup older than 60 days. 
with your actual database name, credentials and path to where you want your backup to live.

Last note: you don't necessarily need to wrap your password in quotes. Some characters will cause it to break without them, however.

Initial Title
bash shell file for daily database backup - Run as CRON job

Initial Tags
Bash, backup

Initial Language