How to Automatically Backup your Database
In this tutorial you will learn how to automatically backup your databases using PhpMyBackupPro. Backing up your mySQL databases is an essential step and can save hours of frustration if something would happen to your databases (hard drive corruption, database corruption, mistakes, rollbacks etc).
When you have installed PhpMyBackupPro and configured it in the way you want, there are 2 alternatives to set up automatic backups.
Alternative 1: Cron
This is a slightly advanced alternative as it might not work at first try, but if it works it works every time. Remember that x10 only allows 1 cron every 5 minutes. If you already have a cron running every 5 minute you need to go with alternative 2, even thought you wont backup every 5 minute, but when the backup runs, the other cron is also running, resulting in your account being suspended.
To use cron, go to your cPanel and choose cron jobs. For large, busy sites you can set it to backup every day, but for most sites, once a week is enough. Choose once a week in the common settings dropbox. The command to use is:
php -q /home/*cpanelusername*/public_html/path/to/backup.php *cpanelusername_databasename* 1 1 1
so if my cpanel username was viggeswe, my database is wordpress and I uploaded pMBP to public_html, the command would look like:
php -q /home/viggeswe/public_html/mysql/backup.php *viggeswe_wordpress* 1 1 1
If you want to backup several databases, you separate them by a comma, like:
php -q /home/*cpanelusername*/public_html/path/to/backup.php *cpanelname_database1*,*cpanelname_database2* 1 1 1
More info about the commands can be found in documentation/SHELL_MODE.txt of your pMBP download.
Alternative 2: Sheduled backup
In the pMBP interface, go to the Sheduled backup tab. As backup period once a week is recommended in most cases. In the Select directory where the PHP file will be placed: dropbox, choose the directory where your site's index.php file is located. Select the databases you want to be backed up, you can choose multiple by holding CTRL. Now click Show script. Before the last include("backup.php"); line, add:
so if I would have installed it in my public_html/dev/ folder, I would have done:
Copy the edited contents of the field, and save it as backupcron.php next to your site's index.php file. Then, at the very end of your index.php file, but before the last ?>, add this line:
You should now be done. Note that the visitor that will trigger the script when time is right will have to wait for the backup to be done before he can see your site!