Backing up your phpBB database using cPanel & cron

The following will enable you to backup your phpBB database using a cron job that will run at the time specified by you. Although this works for on my server it would be advisable to check with your host to make sure this will work on your sever. This is based on cPanel Accelerated 2.
  1. Log in to your cPanel account[/*]
  2. Navigate to the Advanced section and select Cron jobs[/*]
  3. Cron email � You can enter an email address here to receive a notification every time your cron job runs.[/*]
  4. Add New Cron Job[/*]
  5. Common Settings. This contains the most common time settings for the cron job, they include every minute, every 5 minutes, once an hour and a few more. Simply click on the list and select the time needed, the job will run at the selected time.[/*]
  6. If the period required is not on the list use the fields underneath to customise when the job should run. The available settings are Minute, Hour, Day, Month & Weekday. You can enter the relevant details in the box or select it from the drop down list.[/*]
  7. The next field is the place to enter the actual Command, this is what is going to be run at the specified time. The command we will be using is as follows[/*]
date='date -I' ; mysqldump -u DBUSER -pDBPASSWORD DBNAME > /home/sitename/public_html/BACKUP FOLDER/dbbackup_$date.sql ; gzip /home/sitename/public_html/BACKUP FOLDER/dbbackup_$date.sql
Command explanation
date='date -I' - We start by setting the date variable, this will return the current date using the format yyyy_mm_dd

mysqldump -u DBUSER -pDBPASSWORD DBNAME - Next comes mysqldump, this is what backs up the database. All you need to add is your database username, database password and the actual database name.

/home/gadgetbi/public_html/backups/dbbackup_$date.sql - This section tells the above command where to store the sql backup file, in my case a folder called backups, this folder will need to have been created beforehand. The file will be called dbbackup_2011-02-21.sql

gzip /home/gadgetbi/public_html/backups/dbbackup_$date.sql - We then call the GZIP command to compress the file for easier downloading, again the filename will be dbbackup_2011-02-21.sql.GZ, note the GZ on the end.

Once the above has finished running you can use your FTP client and download the backup to your own PC.