开发者

Automatic MySQL Database backup and email through cPanel cron

Can anybody help how to setup 开发者_Python百科a automatic backup of mysql database and then emailing it to me daily?

Thank You.


AutoMySQLBackup gets great reviews. I have not used it but it seems to do exactly what you are looking for. Also, here is another link with different ways to backup, including emailing.


If you're looking to automate your MySQL database backups, say with a cron job, and you host your databases with CPanel web hosting, then there's a PHP script you can use.

You can pick it up here: http://www.hostliketoast.com/2011/10/cpanel-hosting-full-database-backup-script-free-download/


Simple. Not need more.

#!/bin/sh
# Must be installed mutt on your box
mydate=$(date +"%Y%m%d%H%M")
host=$(hostname)
databases='' #'database1  database2 databaseN'

mysqldump --opt --all-databases > /tmp/$host.$mydate.sql
# if not all mysql databases mysqldump --opt $databases > /tmp/$host.$mydate.sql
gzip --best /tmp/mysql02.$mydate.sql
echo "Backup MySQL" | mutt -a /tmp/$host.$mydate.sql.gz -s "Backup MySQL $mydate" -- mail@mail.to
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜