One of the challenges of running a WordPress blog is backing it up. There are so many options to perform WordPress backups, but do you really know whether they will work when you most need it?
Has someone hacked your account? Or a virus scrambled your blog content? Perhaps your hosting service has gone out of business and left you with nothing? Maybe you simply want to move your WordPress blog or web site to a new domain?
WordPress backups are not something that can be left to chance. When you need to be able to restore your web site that you have worked on for several years, you need to have confidence that you can do it.
Unfortunately, many of the available WordPress backup plugins just leave me feeling confused. What exactly are they backing up? Will they actually be able to restore my blog web site in my time of dire need? Do they have enough flexibility to be able to restore onto a different server, in a new directory or even a new domain name?
I run a few blogs and simple web sites using WordPress. Following is my method of backing them up.
I have backed up using this method, and then reinstalled the web site onto a new domain on a different server successfully. If you choose to adopt this method, you should also do a test reinstall to make sure it works. Fortunately I have never had to do a full recovery, but I am confident that it will work for me.
My approach to WordPress backups is based on ONLY backing up the user created content. That is posts, pages, comments, custom fields, categories, tags and all media uploaded to the site, such as photos. This is the content that I have developed over several years and simply can not be replaced if I lose it. This puts you in control of what gets backed up.
I figure that I can relatively easily install a fresh copy of WordPress, apply the theme and load any plugins that I am running. I therefore do not bother backing up these elements.
How to do a WordPress backup
Firstly, ensure that you are running the latest version of WordPress and any plugins. This will minimise any potential compatibility issues should you ever need to restore your backup.
There are two key things that you need to backup to a safe location on your computer.
a) Posts, pages, comments, custom fields, categories, and tags — Install the WP-DBManager plugin. Use the Backup DB tab to do a full backup of your database and save it to your computer using the Manage Backup DB tab.
b) Media — you need to take a copy of all directories and files in the wp-content/uploads directory. You can use FTP, but I prefer to log into my cPanel control panel (you may be running a different system, such as Plesk), select the file manager, and then save a zipped file of the entire directory to my computer.
You have now backed up the user generated content on your WordPress blog. Easy.
You should do this regularly — I have automated the WP-DBManager plugin to email me a database backup once a week. I also take a full copy of the wp-content/uploads directory about once a month. I know that I have copies on my computer of any files that I upload, so taking a regular full back-up of the uploads directory is not as essential for me.
How to restore to the same location
If you simply need to restore to the same location, it is easy.
1) Do a fresh install of WordPress. Ensure that it is the current version. Install the WP-DBManager plugin.
2) Upload the media — Upload the zip file to wp-content/uploads and unzip it. Make sure you do not end up with two uploads directories by accident, ie wp-content/uploads/uploads. You need the media to be in the same location relative to the other WordPress files as they were previously.
3) Upload the database backup file onto your web server in the wp-content/backup-db directory using FTP or the file manager in cPanel (or other system, such as Plesk). The backup should then appear on the Manage Backup DB tab of the WP-DBManager plugin. Select the file and click restore.
4) Apply any themes and plugins that your web site runs.
Your blog or web site should be back up and running.
How to restore to a different location
If you are installing to a new domain name or subdirectory, there is an additional step that you need to do to make the internal web site links work. WordPress uses full URLs to link to media and other content, rather than relative links, so you need to change these.
After importing the database into WordPress in Step 3 above, go into the database (use the cPanel phpMyAdmin utility or similar) and browse the wp_options table. You need to find and change the siteurl and home fields to your new web site address. You should then be able to log back into the WordPress management interface.
You will then need to use a plugin such as Search and Replace to change the rest of the full URL links within the SQL database.
Before you rely on this method for WordPress backups, test it! Do a practice backup, and then do a test restore to a new location, such as a sub-domain. Make sure that all links, both to content and media, work and point to the new web site location.
The usual disclaimer applies.