Kunaljain's Weblog

February 26, 2008

Automated backup script for Mysql

Filed under: MySql — Kunal Jain @ 17:41
Tags: , , ,

Open a file backup.sh and add the following lines in the file. Change UserName and Password with actual Username and Password.

/usr/local/mysql/bin/mysqldump --user=UserName --password=Password --lock-all-tables --all-databases | gzip > /home/user/backup/mysql/backup.sql.gz
cd /home/user/backup/mysql/
CURR=`date +%Y%m%d`
mv backup.sql.gz archives/backup.sql.gz.$CURR

This script create the file in archives folder in a gzip format.


Create a free website or blog at WordPress.com.