Creating a Manual Backup of WordPress When It’s Down or Locked
So your site is down and you can’t log in… and you just realized you don’t have a recent backup. Dammit.Since Snapshot was launched we’ve added sooo much new stuff! Head over to the project page to check out all the new features.
Before you launch into panic mode, though, it’s safe to say you’re not completely screwed. In an ideal world, you would have a working backup that you could use to restore your site, but we don’t exactly live in a perfect world. Sometimes, backups don’t work, get corrupted, or we simply forget (or neglect…) to make one in the first place.
It’s possible to create a manual backup and restore your site manually with FTP, cPanel and phpMyAdmin, which I’ll walk you through in this post. I’ll also go through your options for automated backups so you can save yourself future grief.
Backup Before Contacting Your Host
Creating a backup yourself gives you more control over your site and saves you from having to contact your host, wait however long it takes for a reply, then deal with the possible outcome of there being only a partial backup that doesn’t cover everything or worse – no backup at all.
Best case scenario, there’s a full backup of your server, but restoring it takes too long, especially when you only need one site restored and not your whole server. Plus, if your hosting company finds out you have been hacked or you have an issue that could make other sites on your server vulnerable, they may freeze your account and make fixing the problem no longer an option.
In most cases, your hosting company may not be able to help you create a backup. If they do, consider yourself lucky, but remember that you may not have access to exactly what you need. For example, they may have a backup of your server, but not your individual site.
Contacting your hosting provider can be a great way to get help solving the overall issue, but it’s important that you create a manual backup first so you can potentially avoid these kinds of nightmares while also giving you the option to reset your site yourself if things get even worse.
You could also create an automatic backup, but if you can’t reach your site’s admin dashboard, then a manual backup is your only option. Before you can go ahead and start backing up your site, there’s some important information you need know first.
What You Need to Backup
When you’re creating a backup for your site, it’s important to backup everything including your entire database and all your files. That way, nothing is left out and you can backup anything.
If you create a partial backup, you may not be protected if something goes wrong with the files or tables that you haven’t included in your backup. With full backups, this isn’t an issue and that’s why it’s an ideal option.
Even still, a full backup isn’t always practical or possible. For larger sites, creating a full backup would be a nightmare since its file size would be too huge. Trying to restore such a gigantic file would either not be accepted on your server or it would take up too many resources and throw your site offline.
If you’re in a hurry, a full backup may also be too time-consuming and since you can usually omit core WordPress files since you can download them again. It can be easier to backup only what you need including the files and tables where you have made recent changes.
In these situations, you can create a segmented backup, which would let you either create a full backup in manageable chunks or a partial backup with only the tables and files that have custom data or changes.
When you’re backing up your files, you absolutely must include these:
- wp-config.php – When your site was installed, this file was updated with crucial data that is needed for your site to run.
- /wp-content/ – This folder holds all your uploads.
- Customized files and scripts – If you have made changes to any of your files, scripts or you have a child theme, you need to back these up or your changes could be lost.
While it’s technically possible to gather all the information and files that are included in these, it would be quite the undertaking so it’s best to be sure they’re backed up instead.
When you’re backing up your database, there may be tables you don’t necessarily need to include:
- Inactive plugins or themes – If you have installed extra plugins and themes that you don’t need or use anymore, it’s likely that you can leave out these tables.
- Some plugin data – Some plugins create a lot of bloat in your database because they save lots of reports, for example. If you’re confident you don’t need them, you can leave them out.
- Unchanged tables – If you have tables that are populated with data that hasn’t been customized and that are from plugins, themes or scripts you could re-install, you may be able to leave them out.
Keep in mind that you need to be comfortable with managing your files and database in order to decide what to backup and what to leave out. If you’re not confident with choosing, then it’s safer to create a full backup or a segmented one that includes everything.
Once you create your backups, be sure you verify them to make sure everything that should have been backed up was indeed included. In most cases, you can verify this on a test site, a local install or by uncompressing the backup folder and checking to make sure it’s all there.
With all this in mind, you can start creating a manual backup and this is done in two main steps: Backing up your files and your database.
Backing Up Your Files
There are many ways you can create a backup of your files including using cPanel or FTP. You can also follow the general guidelines presented here to create a backup with your preferred platform.
Backup Via cPanel
After logging into cPanel, go to File > File Manager, then go to the directory where your files are located. To create a full backup of your files, click the Select All button on the menu above your listed files, then click the Compress button at the top of the page.
An inline pop-up should appear next where you can select the type of compression you want and name the folder that is about to be created.
It’s recommended that you choose either Zip or GZiped archive types. Once you have selected one, scroll down in the pop-up to name the compressed folder (your backup). It will be located in the same directory as the files you just selected.
Click Compress File(s) to start creating your compressed backup folder.
If you would like to create a partial backup, only select the wp-config.php file and the wp-content folder in the root of your site. You should also select any files where you made previously changes.
For a segmented backup, visually divide your site into sections. Notice which directories and files are larger and bundle them separately with other smaller files. For one segment, you may only end up selecting five to 10 files and folders at one time or less, but it depends on the size of your site.
You should try to aim for a backup of your files that’s about 20 MB or less in size. The smaller, the better.
For my test Multisite network that has four small sites on it, the full backup I created of the files totaled to one gigabyte. Each of the test sites only has about two posts, six users and 10 pages or less. There are also nine plugins installed on the network.
The backup I created was way too big and I should have segmented it into five parts. While your situation may be different, it should give you a good basis to decide how to segment your files.
Once your files have been compressed into one folder, you should see a list of all the files and what was added. You can click Close to see your backup listed among your files.
Next, select your backup folder and click the Download button at the top of the page. Select a location on your computer and save the file. If possible, copy the backup to as many locations as you can including online storage or burning it onto a CD.
Restoring Via cPanel
To restore a backup of your files in cPanel, upload your backups by clicking the Upload button at the top of the page, then clicking the compressed folder from the list. If you haven’t deleted your backup after it was created, just click on the folder name.
Next, click the Extract button at the top of the page. An inline pop-up should appear where you can choose the directory where you site’s files should be, then click Extract File(s).
If this doesn’t work for you and your old files aren’t overwritten, delete your files, but leave your backups, then try extracting them again.
Repeat this for each compressed folder you have if you chose to segment your full site.
Backup Via FTP
If you would like to create a backup of your files via FTP, I’m assuming you already know how to log into your server from an FTP client and how to transfer files. For details on how to do this, you can check out one of our other posts How to Use FTP Properly with WordPress.
Once you have logged into your server, go to the directory with your site and select all your files and folders or as described above, select your wp-config.php file and wp-content folder, along with any other file or folder where you previously made changes to the original.
In the panel that lists your computer’s contents, choose where you want your backup to go, then move all your files there.
Once all your files have been transferred successfully, you can locate them on your computer and compress them there so it takes up less room on your computer. Don’t forget to save a couple copies elsewhere so you don’t lose your backup.
Restoring Via FTP
When you’re ready to restore your backup, you can uncompress the copy you have on your computer, then log back into your server. In the panel for your computer, locate your files, then select the directory for your site in the server panel of the FTP client.
Delete the files on your server that you’re going to be replacing, then select all the site files from your computer and drag them to your server to start the transfer.
Alternately, you could skip deleting the files before hand and choose to overwrite the files instead, although, deleting the files manually gives you a chance to catch an important file you missed that shouldn’t be deleted, but wasn’t included in your backup.
Repeat this for all your compressed folders if you chose to segment the backups for your full site.
Backing Up Your Database
You can backup your database through phpMyAdmin. Keep in mind that some shared hosting plans may not offer the export option in phpMyAdmin. If that’s the case, you should contact your hosting provider as you may need to upgrade your account or have it enabled.
After logging in, you can create a full backup of your database.
Start by finding the database associated with your site on the left-hand side of the page. When you have located it, click on it once, then on the Export button at the top of the page.
To create a full backup, you can keep the default quick export method and SQL format selected, then click Go and select a location on your computer to start the export.
This process is usually pretty quick, but it may take longer if you have a larger site or you don’t have enough resources available on your hosting plan such as with shared hosting. Once the export is finished, you have your backup ready to go.
If you want to segment or select certain tables to backup, choose the Custom radio button under Export Method instead.
Under the Table(s) section, choose the tables you want to backup. There are certain other settings that are required and may need to be changed from the default.
Here are the other settings and what needs to be selected:
- Output > Save output to a file > File name template – Set to
- Output > Save output to a file > File name template – Check the box labeled use this for future exports.
- Format – Set to SQL.
- Format-specific options – Check the Display comments box and the structure and data radio button.
- Object creation options – Check all boxes except the one labeled Add
- Data creation options – Select the both of the above radio button.
Once these settings are set up correctly, you can click Go at the bottom of the page.
If you’re not sure whether you should segment your backup, you can use the same general rule of thumb for your database as you would for your files.
You can gauge whether or not you need a segmented backup by going off the test site I mentioned earlier. My entire database exported to a size of 1,137 KB, which is fine for most servers.
Keep in mind that some hosting plans may limit the amount of data you can transfer so be sure to check since this is also a great indicator of whether you should segment your backup.
Restoring Your Database
If you chose the Quick option when backing up your database or you didn’t select the Add
DROP TABLE under Object creation options, you need to drop your database tables before restoring your database.
To drop your database tables, log into phpMyAdmin and click on your site’s database from the list on the left.
If you plan on restoring your entire database, scroll down to the bottom of the page and select the Check All box, then select Drop from the list beside it.
If you only want to restore a selection of tables that you backed up, check the boxes on the left of the tables and choose the ones you’re going to restore, then select Drop from the list at the bottom.
Make sure your database is still highlighted and selected on the left, then click the Import button at the top, then click the Choose file button to select your backup file and open it.
Keep the following checkbox under Partial Import checked so that your restore stops if your PHP memory is about to be exhausted:
- Allow the interruption of an import in case the script detects it is close to the PHP timeout limit.
This prevents your site from being kicked offline in the event that your resources are almost exhausted.
Also, be sure SQL is selected under Format and NONE is chosen for the SQL compatibility mode. You can keep the checkbox selected for Do not use
AUTO_INCREMENT for zero values as well.
Finally, click the Go button at the bottom of the page to start restoring your database.
Save Your Future Self: Automated Backups
Keeping automatic backups running in the background of your site can help you out tremendously. The next time your site goes down or gets hacked, you can easily restore your site to working version without hassle.
Since it’s easy to forget to backup your site on the regular, starting an automated backup process is considered essential to website maintenance. You can also use a plugin to create automatic backups for you.
When you’re creating automated backups, the setup is a lot easier when you know what kind of settings are best for you to use.
The WordPress Codex recommends that you keep at least three backups at all times. This means you should backup your site regularly, and keep each of them as they’re created. Once you have more than three, you can delete the older backups so you continuously have three.
It’s also important to store your backups in multiple places. You should have a copy of your backups not just on your server since it could be hacked and your backups could be compromized in the process. This also applies to most other storage spaces.
Keeping copies in multiple locations reduces the risk of losing your backups.
There are many places where you can save all three backups of your site including, but not limited to your:
- Online Storage – Dropbox, Google Drive or others
- Flash drive
When it comes to how often you should create a backup, that depends on how often your site is being updated. If the answer to that is only once a year, you can backup that often. On the other hand, if you write a couple posts a month, a monthly or weekly backup may suit your needs better.
For bustling sites with many users contributing content hourly, a daily backup is likely the best option and even multiple times daily if tons of content is being added.
Recommended Backup Plugins
It can be difficult to know which plugin to use, especially when not all backup plugins are made alike. Some of them don’t include important options such as being able to easily restore your site, send backups to locations other than your server and many aren’t Multisite compatible,
With Snapshot Pro, you don’t have to worry about this at all since you’re covered in so many ways:
- Backup your entire site or partially
- One-click restore
- Automatically processes backups and restores in segments to prevent your site from getting knocked offline
- Schedule your backups
- Save to your server, Dropbox, Amazon S3, Google Drive and more
- Multisite compatible
- Lots more, too
You can also check out details on setting up Snapshot Pro in our post How to Backup Your WordPress Website (and Multisite) Using Snapshot.
To take a look at all your best options and see how Snapshot Pro compares, check out some of these posts:
- 4 Top WordPress Multisite Backup Solutions Tested and Reviewed
- 11 Best Free Quality Backup Plugins for Protecting Your WordPress Site
- 7 Top Premium and Freemium WordPress Backup Plugins Reviewed
- Backup Plugins Aren’t About Backing up, They’re About Restoring
Manually Restoring with Snapshot
If you had Snapshot installed before your site went down and you can access one of your working snapshots, it’s possible to restore your site, even if you can’t get into the admin dashboard.
While this may not work if you exceeded your PHP memory limit, for example, it would work if your site was hacked or a change was made that accidentally brought down your site.
To restore your site, delete it first and install a fresh WordPress site. For details on how to do this, check out the posts How to Uninstall and Reinstall WordPress and A Guide to the Best Ways to Install WordPress.
Next, install and activate Snapshot Pro and restore your site in one more click. Details on how to do this can be found toward the end of our post How to Backup Your WordPress Website (and Multisite) Using Snapshot.
Once that’s done, check your site. It should be up, running and ready to go now.
Once you have regular backups going, you may not have to worry about creating a manual backup ever again, but now you know how to do it just in case.
You may find that your site is down because it has been hacked and if this is the case, you can check out details on how to fix it by checking out a few of our other posts Help, I’ve Been Hacked! How to Troubleshoot and Fix a WordPress Site, Getting Constantly Hacked? How to Stop WordPress Backdoor Exploits for Good and How I Cleaned Up My WordPress Site After It Was Hacked and Blacklisted.
WIN a Share of $5K
Subscribe to our blog this #hostingmonth for a chance to win one of 5 prizes of $1,000 WPMU Dev credit! Learn More.