/ Published in: Bash

Creates a daily backup and deletes any backup older than 60 days.
Replace:
*DB_USER
*DB_PASSWORD
*DB_NAME
*/path/to/backup
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.
Replace:
*DB_USER
*DB_PASSWORD
*DB_NAME
*/path/to/backup
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#/bin/bash /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 {} \;
Comments
