How to Automatically Backup your Database

From Free Hosting Wiki
Revision as of 07:37, 5 August 2010 by Vigge sWe (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Jump to: navigation, search

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. Save the file as cron.php by putting that into the lower field and click save data.

Open your sites index.php file and add this row somewhere between the <?php and ?> tags:


        • I am working on this area, include() and require() madness! ****
Personal tools