blog menu1

Backup-Mysql

Backup - 

[root@mysql backup]# cat dbbackup.sh
MAIL_ADMINS="DEEPAK.KACHOLE@yahoo.com"
LOGFILE=/backup/dbbackup.log
#Clear the Log file
rm -f $LOGFILE
#Backup MySQL Database
if
/usr/bin/mysqldump --verbose --log-error=$LOGFILE -u root -p'abcd' --all-databases | gzip > /backup/database_`date '+%m-%d-%Y'`.sql.gz
then
mail -s "$HOSTNAME MySQL Backup Sucessful" $MAIL_ADMINS < $LOGFILE
exit 0
else
mail -s "$HOSTNAME MySQL Backup Failed" $MAIL_ADMINS
exit 1
fi



Clean Up all files older than 10 days- 

find /backup/ -mtime +10 -exec rm -Rf {} \;

No comments:

Post a Comment