Backup Script
export d=`date +%u`
mkdir -p backup/$d
for i in `echo “show tables” | mysql -u username -ppassword database|grep -v Tables_in_`;
do
echo $i; mysqldump –add-drop-table –allow-keywords -q -a -c -u username -ppassword database $i > backup/$d/$i.sql
rm -f backup/$d/$i.sql.gz
gzip backup/$d/$i.sql
done
The above script will output one gz file per table of the database you specified. It uses Day 1 to Day 7 of a week as the folder names to avoid consuming too much of the disk space.
No comments yet.