mysql backup – shell script

Situation : To create a critical database backup through shell script.

Solution: Create a file and copy the below script into that file. Give excute permission(# chmod a+x to excute that  file.

###Intitiate mysql backup####

echo “Mysql-Backup-job initiated”

MUSER=”your user name”
MHOST=”your host”
MPASS=”your password”
LOGFILE=/root/mysqlback.log (Eg., put appropriate path for the log file according to your requirement)

mysqldump -u$MUSER -h$MHOST  -p$MPASS database name  > /home/karthick/filename.sql

###create a timestamo in a logfile.

date >> $LOGFILE

echo “Mysql-Backup Completed” >> $LOGFILE


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: