Monday, February 3, 2014

Cron Job to Backup the Database(mysql) and send it as an email attachment

mysqldump mydatabase -ujerome -pmypassword > /home/jerome/database_dump.sql
#
#
zip -q /home/jerome/database_dump.zip  database_dump.sql
#
#
mutt -s "Email Subject" -a /home/jerome/database_dump.zip sjnlabs@gmail.com
#
#
rm -f /home/jerome/database_dump.zip /home/jerome/database_dump.sql


add the execute permission to the user

make sure the server forward mails to outside email
 or you may have to setup a forwarder

setup a cron job /home/jerome/backup_commands.sh

No comments:

Post a Comment

About

Blogger templates