Automatically Send MySQL Database Backup To Gmail

Martin Brinkmann
Jul 13, 2009
Updated • Nov 29, 2012
Backup, Development

Webmasters have to make sure that their websites and files are getting backed up regularly to be prepared when something unforeseen happens. This unforeseen event can be a hacker attack, a database crash, a fire in the data center of the hoster or human error. Whatever the cause is it can have a severe impact on the service and business if backups are not available to restore the website or service.

Many web hosting companies offer backup space and create backups regularly. Some on the other hand ask for additional payments or do not offer this backup service at all. It then is up to the webmaster or server administrator to ensure that the data gets backed up regularly so that it can be restored when needed.

One option that is becoming increasingly popular is to backup data and send it to an offsite storage space. Backup2Mail is such a script. It can initiate automatic MySQL database backups on Linux servers using cron jobs and transfer these backups to a Gmail account. The only restriction is that the size of the zipped database should not exceed the maximum attachment limit of Gmail which is currently 25 Megabytes.

The developer provides instructions on how to setup the MySQL database backup and Gmail transfer on his website. It basically means that the user needs to edit an index.php file to provide the script with the MySQL information and GMail data. The only thing left after this step is to create a cron job so that the script is executed regularly on the server. Backups will from then on be created automatically on the web server and send to the Gmail account.


Tutorials & Tips

Previous Post: «
Next Post: «


  1. Rarst said on July 13, 2009 at 6:20 pm

    For WordPress there is decent WordPress Database Backup plugin, easier than setting up cron job. :)

    It works fine except that it once froze and stopped sending backups on WP update (good idea to check all plugins after such).

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.