Thursday, 17 March 2011

simple mysql backup

A simple mysqldump script.. keep only 7 days of backups

#!/bin/bash
USER=root
PASS=your_password

mkdir -p /backup/mysqldump/
find /backup/mysqldump/ -mtime +7 -exec rm {} \;

for x in `mysql -Bse "show databases" -u $USER --password=$PASS` ; do
mysqldump -u $USER --password=$PASS $x | gzip -9 > /backup/mysqldump/$x.`date +%Y%m%d`.gz
done


Linux Server Hacks (v1)

:)

No comments:

Post a Comment