Created
March 4, 2013 12:28
-
-
Save pkdavies/5081943 to your computer and use it in GitHub Desktop.
Simple script to backup a MySQL database and delete files older than two days:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
bkpdate=`/bin/date +%Y%m%d-%H` | |
/usr/bin/mysqldump --user=root --password=yourpass --lock-tables=false --databases list_dbs_here > /databases/backup-${bkpdate}.sql | |
/usr/bin/zip /databases/backup-${bkpdate}.zip /databases/backup-${bkpdate}.sql | |
for file in "$( /usr/bin/find /databases -type f -mtime +2 )" | |
do | |
/bin/rm -f $file | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment