PDA

View Full Version : Automatic Database Backups



Koobazaur
08-05-2007, 05:39 AM
Greetings,

I would like to automate my MySQL database backups. If I understand correctly, HostMoster already backs up my databases, which I can retrieve via the "Backup" panel (how often does it do that, though?). This is nice, but I would like to be able to auotmatically backup stuff and store it on my end. I figured the easiest solution would be to email my database backup to another email specifically for that (such as yahoo or gmail). However, I am having a hard time doing this.

I already got the CRON command to create a database backup file:
/usr/bin/mysqldump -u user -p[password] database_name > /path/to/my/file.sql

However, I wanted to email the output instead of saving it to a file. Does anyone know how do I do that?

Also, is it unsafe to keep my password in my cron table? I wanted to do it via a PHP file but couldn't get the above command to work with exec().

Lastly, does anyone know what exact permissions are required for the user that does this dump?

Thanks

sjlplat
08-05-2007, 12:59 PM
The PHP mail() function can do this. Since the backup has already been generated, simply use a Cron job to email the file a few minutes after it's generated.