As every WordPress site consists of a database as well as the files uploaded in the public_html folder, backup and restoration are not as simple as it is with HTML websites. In fact, many people find it confusing. However, web server failures, hackers, and even acts of nature can cause a complete loss of information on any site. Precautions can be taken to try to prevent some of these things from happening, but having a complete backup of the WordPress site is the only thing that will allow it to be restored if something does go wrong.
Fortunately, the process of backing up a WordPress site, as explained in the following, does not need to be very complicated and can be carried out by anyone.
WordPress backup plugins
There are some plugins that are designed to automate the backup procedures, but solely relying on these plugins is not a good idea. Plugins can become outdated or not work for other reasons, and people can easily find themselves lacking a working backup copy. If this happens with a site run by someone who is not familiar with how to manually backup a site, all their work may be lost. Therefore, while using plugins is fine, it is important to understand the process and have at least one manual backup in reserve.
Understand the process
There are two parts to backing up a WordPress site, which is something that a lot of people do not realize. First, there are the actual files for the site. This includes the base WordPress files that could be downloaded again, but it also contains the theme and plugins that have been added to the site. In some situations, these files can actually contain information that cannot be replaced by simply downloading the original files again.
In addition to the files, all WordPress sites have a database. This contains most of the settings and other customized information for a site, which includes the actual page content and blog posts. Many plugins that backup WordPress may only target the database tables. They are extremely important but alone they are not a complete backup of a site.
Backup website files
The actual process of obtaining a copy of the files for a site can vary because there are many different ways to do it. Some website hosts will offer an easy way to download a copy of an entire site, which can also be used to restore the site as well. These can be useful time savers, but they are still automated systems that can fail.
The most reliable way to backup all the files from a site is through FTP. To use this method, FTP software is needed to make a connection with the site. Then, all the files from the public folder of the website can be copied to the local computer. This copy can additionally be stored in the cloud or some other type of external storage media, which provides two copies of the backup that could be used to restore the site.
While it is probably a good idea to simply back up all the files in the public_html folder, the wp-content, .htaccess and the wp-config.php files (along with the database explained below) are all that are absolutely necessary to fully backup a site.
Backup database tables
Completing a backup of the database tables is generally a more confusing process, but it is definitely the most important step to learn. The first step is to access the database. This is done by logging into the website hosting cPanel (this is what most hosting services use) and clicking on the phpMyAdmin shown on the left.
In phpMyAdmin, find the main database for the WordPress site in the drop-down menu in the top-left of the page (database wrdp1 is selected below). If multiple installations exist on the same hosted domain, it can be confusing to tell which database belongs to which website. The easiest way to identify a site from here is to visit the “wp_options” database table. The initial options listed in this database table will identify the domain name and the blog name.
Once the database to backup is identified, make sure the page shows a full list of all the tables in that specific database, which was the view that was first seen when the database was selected. Then, click on the “Export” link along the top of the page.
From the Export page, just click on the “Go” button to export all the tables from that database. This should be set to be done in “SQL” format by default, which is the best format to use when restoring a database. After exporting the database, phpMyAdmin will present a file to download. This file should be treated just like the backup of the site files.
Note, the database selected in this example was _wrdp1.
Restoring a WordPress site from backups
The process to restore a WordPress site from backup files is basically done in the reverse order. It is a very good idea to try out this entire process on a test website for the first time. This will help to ensure it is done correctly, which will make a major difference if the backups are ever needed.
First, the database backup file should be uploaded through the “Import” link in phpMyAdmin. If the database does not already exist where the backup will be restored, it should be set up manually from the cPanel. Simply click on the MySQLDatabaseWizard icon (shown in backup database above) and follow the step-by-step instructions. This must be done using the database name, user name, and passwords found in the “wp-config.php” file from the WordPress site backup.
Some web hosts will have a limit on the file size that can be uploaded using this process. This is another good reason why the process should be manually tested by anyone who runs their own WordPress site, since backups may need to be made with custom settings or split into multiple pieces to ensure they will be able to be restored.
Next, upload all the files to the site through FTP. This should be quite a few files to upload, so it can take some time. If uploads fail to complete, they may need to be done in a few different pieces to ensure all the files are getting uploaded. If this is being done to repair an installation for a site or over a new installation, existing files should be overwritten when uploading the backup.
Doing a clean install from a backup
When a site has problems that cannot seem to be corrected, sometimes it is best to simply do a clean install from a backup. If this option is chosen first make sure to make a backup of all content from Dashboard/Tools/Export. Note, this will not include theme and plugin settings so be sure these are known or backed up. In addition, the wp-content folder should also be backed up through FTP. After this is done, delete the old site and do a fresh install of WordPress. Upload the wp-content folder again and import the backup file as well as any settings for themes and plugins (it may be a good idea to delete and re-install the theme and plugins since they will be from the old site in the wp-content folder).
More details on how to do a clean install can be found at easy WordPress repair.
Fast and easy but not free
For those who would like a faster and painless way to backup and restore an entire WordPress site, there are paid programs that will simplify the process into a couple of clicks and remain current. WP Twin is currently the most reliable option on the market for site owners willing to invest in software to do the job.