Guest Post: Backing Up WordPress for Fun & Sanity

Categories: Guest Posts

Today we have a guest post from Phillip Erb of the NEPA WordPress group.  Phillip Erb and Joe Casabona will presenting a session on WordPress Customization & Security in the Technology Track.

You have a great idea for a new blog post, so you fire up your web browser and hit your site. Of course, you’re sitting at your homepage, because (like me) you forgot, yet again, to put “/wp-admin” at the end of the URL. You’re about to go there when you realize that something isn’t right. Your image slider isn’t sliding or your latest tweets widget isn’t showing up. Maybe the site color scheme that you changed a few days ago just isn’t tickling your fancy. Or perhaps your posts have been replaced with Viagra ads.


That sinking feeling hits yours stomach.


Hopefully you’ve never been there. Awesome, but don’t let it go to your head. Whether you’re sites been hacked, a plugin or theme update has gone bad, or you just goofed up, the chances are pretty high that, someday, you’ll need to restore your site from a backup.


But you have to have a backup, if you want to restore from it.


Oh, your hosting provider does backups? Great, let’s call it a day.


Hopefully you read that with the sarcasm in which it was intended. The reality is that your hosting provider may keep backups, but you are completely at their mercy in terms of what is backed up, when and how often it is backed up, how long the backups are retained, and how long it will take to restore your site.


I always recommend having your own backup plan for your sites. If your provider does do some form of backup, I would much rather have more backups than too few. Personally, I use a two stage approach to backups:


  1. Scheduled backups of the web files and MySQL database on the server.

  2. Backup plugin for on-demand backups.


Many of the backup plugins for WordPress – the good ones, at least – offer the ability to schedule backups. I prefer to run a scheduled script on the server to do my automatic backups. This provides the added benefit of separating my backups, so I’m not fully relying on one method to safeguard the sites that provide me with a source of income.


Your ideal backup plan may be similar or you might not be as paranoid as I am. The plan has to make sense for your site and you have to be comfortable with the level of protection that you’re setting up.


I’m going to show you two methods for backing up your site, which you can customize to fit your needs – perhaps sending a backup to Dropbox or Amazon S3 for off-site storage.


Scripted Backup of Files and MySQL


On my own servers and on all of my clients’ hosting packages, I have SSH access, which allows me to run BASH scripts. I use a fairly simple script to backup the database and web site files to a ZIP file. The drawback to this script is that it stores the backups on the web server, but it could be easily modified to transfer the backup to another FTP server or you can manually download them to your local computer.


It’s best if you have a bit of Linux know-how to implement this script. Here’s the basic rundown:


  1. Create a directory to hold the backups (i.e. /home/myuser/mybackups/)

  2. Copy the contents to a file on your web server (i.e. /home/myuser/, modifying the appropriate variables.

  3. Set executable permissions on the script file

  4. Setup a cron job (scheduled task) to run the script on a regular basis.


The script will create backup files, in the folder you specified, with names like “mysite_201309281944” (mysite, backed up on 2013-09-28 at 19:44).


#set -xv

#Edit these variables









#Stop editing

dateTimeStamp=`date '+%Y%m%d_%H%M'`


#Create database dump

mysqldump --user=$dbUser --password=$dbPass --host=$dbHost $dbName > $dbBackupFile

#Zip files

zip -r "${backupDir}/${siteName}_${dateTimeStamp}.zip" $siteFolder $dbBackupFile

#Remove database dump

rm -f $dbBackupFile

#Remove old backup files

find ${backupDir}* -mtime +${daysToKeepBackups} -exec rm {} \;


BackWPup Plugin


When you install and activate the BackWPup plugin, it adds a new section to the WordPress dashboard. By default, this section is only available to site administrators, but other users can be given BackWPup roles. For the purposes of this post, we’ll just be talking about the options available to the admin.


Let’s assume that you want to setup a daily backup job of all web files and the database, saving to a folder on the web server. Note that these settings can easily be changed to backup to another location, run the job manually, or backing up different items.


To create a new backup job, go to BackWPup, then Add New Job in the dashboard.




  1. On the General tab:

    • Enter a job name (i.e. “Daily Backup”)
    • Select Database backup and File backup
    • Select your preferred archive format. Most people will likely choose Zip as they can easily open it on their computers without additional software.
    • Select Backup to folder. Note that there are various other options, like Dropbox, FTP, and S3 services.
    • Verify the backup log information – this is automatically populated with your site’s e-mail address, as defined in the WordPress general settings.
  2. On the Schedule tab:

    • Select with WordPress cron
    • Under the scheduler, select daily and choose the time when you would like the backup to occur.
  3. On the DB backup tab, verify that all database tables are selected.

  4. On the Files tab, select the checkboxes to include all files and folders. I don’t recommend excluding anything, unless you know that you absolutely won’t need it when you restore your site. Exclude cautiously!

  5. On the To: Folder tab:

    • Enter the folder path where you want the backups saved.
    • Enter the number of backup files to keep. Note that this is not the number of days to keep a backup. If this job is only run daily, a backup will stay around for 30 days. However, if you also manually run this job, you run the risk of deleting backups sooner than you think. If you want to manually backup the site, in addition to an automatic job, please create a manual job.


The most expensive backup is the one you don’t make


I wish that I could say the day will never come when you’ll need to restore from your backups. I sincerely hope it’s true, but I’m not willing to take that risk and I hope that you aren’t either.


These are two free options for backing up your site. There are several other options out there, including some worthwhile paid options such as BackupBuddy by iThemes and VaultPress by Automattic.

The question you face is … what are your data and your peace of mind worth? Only you can make that call.

Author: Michelle Davies

Michelle Davies is a married mother of two beautiful little blossoms and she lives with her family in Sweet Valley, NEPA. She’s been blogging for 10 years and is the mastermind behind the award winning NepaBlogs.Org. She works at local news station WNEP as an IT superstar. She graduated from Leadership Wilkes-Barre in 2010. She is an active volunteer in the community.

Leave a Reply