I have to have a backup of the MySQL database daily, and ideally get it email itself to their email of my selecting.

Can you really do that? What's the SQL to develop a backup file? How do i add this file being an "attachment" towards the email that is sent?

Just help, I really should make these backup copies!

I know how you can call a script via cronjob, therefore the daily factor isn't a problem.

Simply drop to some command spend and operate a mysql_dump command like so:

mysqldump <DB name> -u<user> -p<password> | gzip -c > /backup/`date +%Y-%m-%d`.sql.gz

From here you can easily make use of the mail command (I'm not sure the syntax off hands to add personal files).

You should use [cde] to call mysqldump within the command-line to produce a backup of the database to some file of the selecting.


Then in PHP, you are able to locate the file and upload being an attachment and send it.

I don't understand how safe delivering the database is by e-mail, if there's alternative solutions I possibly could suggest, I'd.

Per Tom's comment, have a look at PHP Zlib and creating GZIP files "on the fly" to zip files through PHP.

Automatic MySql Backup Script

This script finds all the MySQL databases in your server, individually backs them up, compresses them, and stores the file inside a specified directory and/or emails it for you. It's been up-to-date because the initial public release and includes several additional features.


I did previously use

MySQL database backup ===================== http://restkultur.ch/personal/wolf/scripts/db_backup

However it's a little old, and I am unsure when they upgraded the version etc. However it is effective, and givse you large amount of backup options (the number of days to help keep, several weeks, in addition to where you can keep file - it may be submitted via FTP to a different server for redundant security).