Backing up your website is important for several reasons. One being that in case of emergency you will have a copy of your website which you can use for restoring the website to a previous functional state. In this tutorial, we take you through the steps you need to take to backup your WordPress website and how to restore your WordPress website backup. This process equally applies to many other Content Management Systems (CMS).
How to Backup Your WordPress Website
In WordPress, the process of generating the backup is quite straight forward and we will explain it in details in this tutorial. WordPress is a php/MySQL driven platform and so you are required to perform the backup on two stages.
To create a backup of WordPress, you need to take the following steps:
Step 1: Back up the files
Step 2: Back up the Database
Back up your files
The first step you need to take is to backup the files for your website. This can be easily done via the FTP service for your account. If you are not quite sure how to use this service or if you are not entirely familiar with it please check our FTP tutorial series.
Once you connect to the FTP service for your website and access the root folder for your website (where the WordPress files are located) you will need to download them in a folder on your local computer.
Once you are done downloading the files you will need to backup the database your website is using.
Read related WordPress tutorials:
7 Security Tips for a WordPress Website
How to Backup Your WordPress Website Automaticaly Using Backup Plugins
How to Keep Your WordPress Website Updated
Backup the Database
To backup your database, you need to know the name of the database used by your website. If you are not quite sure about the database name you can easily check it by opening the wp-config.php file and searching for the following line in it:
Once you find the database name you will need to locate the database and export it. The export process is also an easy one to handle, it will require however for you to access the phpMyAdmin application located in your cPanel area.
There from the left vertical column view you will need to locate the database name and to click on it.
Then you will be presented with the table view for your database. Here you will need to use the Export tool in order for your database to be properly exported. This tool is located in the top horizontal menu at the table view page.
Once you press that button you will be redirected to the final exporting interface where you will need to simply click the Go button for the export process to begin.
Then a file will be prompted for download and once the download is finished you will have a backup of your database on your local computer. Considering the fact that you have already downloaded the files of your website via the FTP service and also the database you are done with the backup of your website.
Read more WordPress tutorials:
How to Manage 403 Forbidden Error in WordPress
How to Optimize and Speed Up Your WordPress Website
How to Restore Your Website Backup
Usually you will need to restore a backup for your website if some issue has occurred with your website and it is resulting in your entire website being down. We suggest that before you consider a backup restore, try to resolve the issues which could simply require overwriting some files. If all your repair efforts fail, then, restoring your backup will be your last and best option.
Of course in order to restore a backup you will first need to have one created at some earlier point of time. If you are not quite sure how to generate a backup for your WordPress based website please check the section above on how to backup your WordPress website.
Assuming that you have the files and folders along with the database of your WordPress website you will need to begin with restoring the files.
To restore WordPress from a Backup, you will need to:
Step 1: Restore the files of your website
Step 2: Restore the Database
Step 3: Edit the Configuration File
Restore the files of your website
This can be done quite easily using the FTP service. If you are not quite familiar with the FTP service you can check our FTP tutorial series.
Assuming that you have successfully connected to the FTP service for your website you will need to navigate to the folder where the files for your WordPress website are stored.
Once you find them you will need to upload the files from your backup (stored on your local computer) over the files of your current website overwriting all of the existing files.
Once the upload is finished it is time for the database of your website to be restored.
Restore the database
This can be done quite easily if you create a new empty database and import the backup you have stored on your local computer. If you are not quite sure how to create a new empty database, create a new user for that database and grant the user privileges to operate with the newly created database you can check first section of this tutorial where we have given a guide or you look at our tutorial on cPanel database management.
Next you will need to access the newly created database in the phpMyAdmin application available in your cPanel -> phpMyAdmin.
Once you access the phpMyAdmin application you will need to find your newly created empty database in the vertical tree-view located at the left of the page. As soon as you find it click on it so you can browse the table view and then use the Import button located at the top vertical menu.
The Import button will redirect you to the importing interface where you will need to select the backup file store on your local computer. Usually that is an .sql file you have received after exporting your database earlier.
If you are done selecting the backup file you will need to press the Go button at the bottom of the page so the backup can be imported successfully.
Up to this point the restore is completed, however you will need to tell your website to use the newly created database which you have restored the backup into. That requires that you edit your configuration file.
Edit the Configuration File
This is quite an easy task and in order to do it you will need to edit the code of the wp-config.php file. This file is located inside the files you have just restored and in order to edit it you can use the Code Edit option of the File Manager featured located in your cPanel.
This feature will bring the code of the wp-config.php file for editing. Please change the following lines from that file:
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
by replacing example_database with your new database name, example_user with the actual user you have assigned to operate with the new database and last but not least the “pass1” with the actual password for the user you have created.
Once you are done with the edits please use the Save Changes button located at the top of the page in order for the changes to be saved. If you find any issues, you can contact the customer support of your web host. That will be all you need to do to backup and restore a backup for your WordPress website
Reasons a Backup for Your Website is Necessary
1. Protects you Against Human Error
Human errors are most likely with every web developer or manager. It is normal and everyone make mistakes from time to time. You might delete an important file on your website, make a change that breaks some of its functionality, and make some other mistakes. There are ways to fix these kinds of errors, but in some cases, fixing the mistake can be a difficult task and a proper thing to do to have your website back is to restore a previous backup.
To put this into perspective, imagine that a significant part of your website ceases to work. You have two options:
Identify the problem and look for a way to solve it.
Restore your website’s most recent backup and move on.
The first method can be quick or take a lot of time, depending on how serious the problem is. However, with the second approach, you can have your site up and running quickly. All you need is a recent functional backup that you won’t lose any valuable data.
The primary takeaway is that backups can save you in situations where you or someone else makes a mistake on your site. To be as safe as possible, you’ll want to create those backups frequently — even on a daily basis
2. Correct Problems During Updates
Updates are necessary to keep your site functioning smoothly. At the same time, it’s not uncommon to perform an update to your site, only to see something unexpectedly go wrong. That doesn’t mean you shouldn’t make changes — you just have to go about them safely.
Ideally, you’ll have an automatic backup system set up for your site. That way, if you update any of its key components, you’ll have a recent restore point available just in case. It’s also smart to make a manual backup before you start tinkering with your website.
It might take you a few minutes or longer to get that backup ready. However, you’ll be happy you made the time if anything goes wrong during the update process.
3. Prevent Data Loss
Imagine that you have a blog with hundreds of posts, and someone on your team deletes one (or more) of them by mistake. In the past, we’ve seen people delete entire libraries of content because they didn’t know what they were doing or they gave certain users too many privileges.
One of the primary reasons to maintain a backup system is to ensure that your data will be safe, even in situations like the one described above. That means you need to have a full backup of your site in place, and the same goes for your personal data as well.
What’s more, data loss can occur even if there’s no human error involved. That means having backups is essential, even if you and your team know what you’re doing.
If you’re worried about losing important data, we recommend you take things one step further. Not only should you have multiple backups available, but you should also avoid keeping them all stored in the same location. We recommend uploading your latest backups to the cloud, as well as keeping a copy on your server for redundancy’s sake.
4. Manage Compatibility Issues After New Installations
If you use WordPress or any other Content Management System (CMS), then you probably rely a lot on add-ons, such as themes and plugins. Both types of tools can be incredibly handy. However, each time you install a new add-on, you’re introducing an element that might not play nicely with the rest of the site’s ecosystem.
Just as with updates, this doesn’t mean you should avoid plugins and themes. Instead, what you need to do is be careful about the ones you install. Make sure they have good reviews and ratings, and that the developers update them frequently.
You’ll also want to back up your website before you activate a new theme or WordPress plugin, just to be safe. With this approach, if a compatibility issue pops up, all you have to do is revert to a previous backup. Then, you’re free to install an alternative tool.
Also read: How to Keep Your WordPress Website Updated
5. Resolve Malware Infections
A surprising number of websites are infected with some kind of malware, and a lot more of them are vulnerable to it.
Even if you’re proactive about website security, attackers have highly-sophisticated techniques in their arsenals. Also, keep in mind that not even smaller, lesser-known websites are safe from attacks. WordPress users, for example, often face threats from bots looking for vulnerabilities they can exploit.
Troubleshooting malware can be particularly tricky since it’s hard to know when your site is fully clean. Even then, if you don’t identify and patch the security ‘hole’ that led to the infection, you’ll remain vulnerable. Having a backup ready to go will help you get your website clean faster.
6. Provide Protection Against Hackers
There may also be times when attackers try to access your site directly to deface it or steal important information. If someone manages to breach an account with administrative privileges, for example, they might change its credentials to lock you out of your site.
This shouldn’t happen if you take the right security precautions. It’s especially critical to have Two-Factor Authentication (2FA) enabled on your site. If there is a hack, however, there are three ways you can proceed:
Try to recover access to your account through your email.
Contact your web hosting provider to ask for their assistance.
Restore a backup from your hosting panel.
The first option might not always work since attackers will probably change the email associated with the account right away. If you’re using a reputable web host, the company should be able to help you — but that can take time.
Restoring a backup, on the other hand, can help you regain control of your site quickly. Once you do, you can update your credentials to ensure that attackers are locked out once more.
Also read: How to Fix a Hacked WordPress Website
7. Simplify the Process of Migrating Web Hosts
There are times you mae a wrong choice of web host and after some bad experiences you may need to migrate from one web host to another. The process involves moving all of your site’s files from one server to another. The good news is that if you’ve taken our advice to heart, you already have multiple full copies of your website ready to go.
There are a lot of ways you can use backups to migrate your website. You can copy files manually, use dedicated tools, or ask your new provider to do it for you. In any case, having a backup ready means that you can switch web hosts at a moment’s notice if you need to, which gives you a lot of freedom.
8. Create a Testing Version of Your Website
The safest way to make changes to your website is by using a testing environment. That way, if something goes wrong during or after the update, you can keep it from affecting your live website.
To do this, you’ll need what’s called a staging site. There are several ways you can go about creating one, and they’re all pretty straightforward. What’s more, having a recent backup of your site in place means you can be ready to set up a staging copy in minutes.
9. Prevent Interruption in Revenue Stream From Your Website
If you monetize your website, then you need to ensure that it’s always accessible. Every minute that it isn’t working can cost you money. It’s important not to lose out on any potential earnings due to problems with your website.
Troubleshooting unexpected problems from scratch can take a lot of time, as we mentioned before. On the other hand, if you can restore a backup, you’ll get your website back online and earning money quickly. Then you can take your time to find out what went wrong in the first place and keep it from happening again.
10. Backups are a Strong Security Practice
Backing up your data, in general, is the cornerstone of good digital security.
If you take your website seriously, you’ll also want to read up on the other best security practices you can implement. However, the first step is to create a backup right away and repeat the process often. Sooner or later, it will save your site so never ignore maintaining a safe backup.