Surf 11 » My MySQL Backup Script

Finding the best waves on the web.

Here's a simple mysql backup script that uses mysqldump, and keeps the previous two backups in gzipped tar files.

#!/bin/bash
#makes a backup of all databases in the db list
dblist="db1 db2 db3 etc"
backup_dir="/home/backup"
for db in $dblist
do
mysqldump $db > $backup_dir/mysql/$db.sql
done
if [ -f $backup_dir/mysql.2.tar.gz ]
then mv $backup_dir/mysql.2.tar.gz $backup_dir/mysql.3.tar.gz
fi
if [ -f $backup_dir/mysql.tar.gz ]
then mv $backup_dir/mysql.tar.gz $backup_dir/mysql.2.tar.gz
fi
tar -czf $backup_dir/mysql.tar.gz $backup_dir/mysql/

You will want to edit the dblist and the backup_dir to point to a directory that exists, and also create a mysql directory under it.



Related Entries
On at Holly wrote:
1
Well done! http://pfkculcw.com/wlkd/hjbg.html | http://niitmnfp.com/qbnr/hsxd.html

On at dtoabzigaj wrote:
2
Hello! Good Site! Thanks you! tlpkgxnkigtfs

Name:

Email: (optional, not displayed on site)
   Subscribe to this thread
Comments: (html will be escaped)



Subscribe to our RSS Feed: subscribe to this feed XML
Archives   Tags   Contact