Ensure WordPress Backups Can Be Restored Successfully Before You Add Any Content You Don’t Want To Lose!!!
Before you add any WordPress content you MUST ensure that a backup and restore process is in place. The importance of this cannot be over-emphasized. Every hour that you spend adding content to your website can be erased if the database crashes – databases do crash, and this is fair warning.
Before adding content make sure that your website administrator has a backup scenario in place and that regular backups have been verified.
To perform manual full or partial MySql database and file backups you can go into the website cPanel and click the Backup Wizard in the Files section then select the backup options you want. A full backup backs up everything about the site including email configurations and all site files. Partial backups can include one or all of the following:
Email Forwarders and Filters
When these backups are performed they will be placed in the root folder of the website:
To extract (and possibly restore) only the WordPress database file you need to open the tar file that is backed up and extract the .sql file in the .\mysql\ folder. A typical file is named domainsp5_sswp01.sql.
AUTOMATIC SITE BACKUPS
This is our normal automatic backup process:
Backup WordPress MySql Database – to automatically backup the WordPress MySQL database (and all other website MySQL databases) at BlueHost.com we run a WordPress backup script named backupDatabases.sh that resides in the root folder of the website. You must set the permissions of the Owner user for this file to allow executes. This requires a security setting of 744. This backup script is usually run daily unless a lot of content is being added in which case we’ll run it 4 times a day. To run the script automatically you need to create a CRON job for it. CRON jobs are explained below. The backups it creates are located in this folder of the website:
A CRON job is simply a scheduled task in Linux or any Unix-based machine.
You can run CRON jobs from your cPanel (Advanced – last section at the bottom of the page) to execute the first set of backups described above. You can change the frequency of these backups by clicking the CRON Jobs icon.
WordPress MySql Database Backup Script
The backup script described in this page allows you to create automatic backups of your MySql database when you use it in a CRON job.
All of the content below the line under this sentence with all ### should be copied to a file named backupDatabases.sh. Once this is done you need to do the following to set up your automatic database backups:
- Change the user and pass variable values in the Configuration settings to the login values for your website control Panel.
- Place the file into the root folder of your website account (this may not be your website root folder).
- Using your FTP client change the permissions of this file to 744 so it can be executed by the site Owner user.
- Refer to this file in a Linux CRON job and specify how often you want your MySql database backed up.
- Test it. Make sure that the files are actually created. This is important to the well being of your website. If you have problems see the troubleshooting page.
Note that the files are placed into this folder of your website:
# FILE: backup_db.sh
# USAGE: ./backup_db.sh password
# DESCRIPTION: Backup all my databases one by one
# VERSION: 1.2-STABLE
# CREATED: 11/28/08 11:42:00 MST
# REVISION: ---
user="CPUsername"; #A Database User with Privileges on all dbs
pass="CPPassword"; #Said user's password !!
#-----Don't Edit Below This Line-----#
if [[ `uname` = "Linux" ]];
mystat="stat -c %Y";
if [[ `uname` = "FreeBSD" ]];
mystat="stat -f %B";
ts=`date +%s`; #For the file timestamps
d=`date +%Y%m%d-%H%M`; # For other uses
month=2592000; #One month
#month=178200; #2 days For testing
dir="$HOME/backups/"; # Directory to store the backups
if [[ ! -d $dir ]]; #Make sure the dir exists and create if not.
mkdir -p $dir;
# First let's prune the backup dir of files over a month old
for l in `ls $dir`;
# Works CentOS and Ubuntu...
do mt=`$mystat $l`;
if (("$result" >= "$month"));
echo "Deleting: $l";
rm -f $l;
# Let's do this
for i in `echo "show databases" > $expath/mysql -u$user -p$pass > grep -v Database`;
$expath/mysqldump -R -p$pass -u$user $i > $var.sql && echo $i backed up on $d;