Performing a backup allows you to save your WordPress website and in the event of a problem, restoring it to a previously saved state.
The process of backing up and restoring your website is extremely important as it safeguards you from the possibility of losing everything!!
In this tutorial, you will learn to how to make complete backup of your WordPress database and files.
You will then learn how to restore your website to a previously backed up version.
*this lesson has been retired from out WordPress course because the plugin recommended here is no longer actively maintained. We’ve posted the lesson here anyway because all the same principles apply, we now recommend the BackWPup plugin (free) or BackupBuddy (which is excellent, but kind of expensive $247).
When backing up your WordPress site there are two separate things to consider:
- The Database – where all your content is stored
- The Files that make up your WordPress site
Your WordPress database contains every post, every comment and piece of content you have added to your site. If your database gets erased or corrupted, you stand to lose everything you have written. There are many reasons why this could happen and not all are things you can control. But what you can do is back up your data.
The files that make up your website include your theme, all your plugins and all the media files (i.e. images, documents etc) that you uploaded to your website. There is nothing worse than realizing all the hard work that went into developing your website has all been lost due to a silly human error or the malicious activities of a hacker.
Making backups is essential because if anything goes wrong with your site – then you can restore to a previous working version.
When are backups necessary?
- If a WordPress/plugin/theme upgrade causes a conflict and breaks your website
- If you’re website gets hacked and your database or files get corrupted
- If your hosting account gets hacked and your files and database are compromised
- If you decide to move hosting companies
Taking a Backup
The easiest way to backup your WordPress site is doing it automatically with a backup plugin.
The Online Backup for WordPress plugin enables you to take a complete backup of your WordPress files and database.
Step 1. Install and activate the Online Backup for WordPress Plugin
- Go to Plugins > Add New
- Search for “Online Backup for WordPress“
- Hit Install
Step 3. From your dashboard, select Online Backup
Step 4. Select Backup from the options menu
Step 5. Generate a full back up (with database and files)
- Ensure Database is selected to backup your database
- Ensure FileSystem is selected to backup the files that make up your site
- Select Bypass Encryption: which is an extra security step that ensures that hackers can’t access your backup file should it become compromised
- When ready, select Start Manual Backup
Step 6. Save / Download the backup file
- Ensure there is no errors (warnings are ok)
- Download the file to your computer
The back up zip file that was downloaded to you will will contain 2 folders:
- Database – containing a single large text file (called a SQL file). The text file contains all the instructions needed to rebuild your database
- File System – Containing all the files and folders in your public_html folder
That’s it! Your website is now safely backed up should you ever wish to restore it to its current state in the future.
- Once your website is at a stage where you are happy with it
- After you perform an update that you don’t want to lose
- Before you update WordPress
- Before installing or updating any plugin or theme
- If moving to another hosting company
The second part of this exercise simulates a scenario in which your site has been hacked.
You will now be stepped through deleting then restoring your WordPress database.
If you not familiar with operations such as creating folders and unzipping files, then please mark this lesson as complete and move on to the next exercise.
Important: Only proceed with this exercise after you have taken a backup (see above)
Step 1. Login to your cpanel account.
Step 2. From CPanel, select PHPMyAdmin
Step 3. Select Databases to list working with
Step 3.1. Select your database from the list
Unless you have multiple websites installed you should only see one database listed here.
Step 4. Drop (i.e. delete) the existing database
Your database consists of a large number of tables. To remove the database you must select all the tables and drop them
- Scroll down to bottom of all the tables
- Select Check All
- Select Drop from the drop down menu
Step 5. Confirm that you wish to drop the database
Step 6. Visit your website to see the damage
With no database – you have no website. When you visit your homepage you will now see an installation screen – which is the starting point for people who install WordPress manually (you installed WordPress automatically in an earlier exercise).
At this point you have no website. You now need to restore your database.
Step 7. Unzip the backup file you download previously
- Create a new folder on your computer called BACKUP
- Copy the zip file into the folder
- (Windows users) Right click on the file and select Extract All…
- (Mac users) Simply double click on the file
Step 8. Import your backed up database
- Return to PHPMyAdmin
- Select Import from the menu
- Browse for the SQL file in the Database folder (Browse to the backup file > Database)
- Hit Go
Step 9. Go back and visit your website to confirm it worked!!
Go back and visit your website; it should now exactly as it did before!
It may not seem very exciting right now -but the ability to perform a full backup and restoration of your website means that you are prepared for a worst case scenario – and it might just come in very handy someday.
One possible type of attack on your website involves the hacker injecting malicious code into the files that make up your website. This type of attack passes the virus on to visitors of your website – and quickly gets you unlisted from Google
In such a scenario you will get a notification from your hosting provider.
If your files get damaged or corrupted then you will need to delete them and upload the backed up versions.
Again, if you are not comfortable with zipping files then please mark this lesson as complete and move on.
Step 1. Prepare the backed up files for upload to your server
What we must do here is a) locate the public_html folder inside our backup, b) zip it up and c) replace the files on our web server with the back-up by uploading our newly created zip file to the server
- Browse to the unzipped backup file – i.e. the folder you created when you unzipped the backup file (Step 7 in the previous section)
- Browse to the file system folder
- Right click on the public_html folder
- Select Send to > Compressed Folder – this creates a zip file of just this folder
Step 2. From the control panel, Select ‘File Manager’
*if asked – jump to the Web Root directory
Step 3. Delete all the files in your public_html folder
You can now see all the various files and folder that make up your WordPress website.
- From your root directory select the public_html
- Click on the Select All option
- Hit Delete
Step 4. Check your website.
With no files on your server your website will be a blank page.
Step 5. Upload the public_html.zip file
- Select Upload from the file manager menu
- Browse for the public_html.zip file
- Confirm that you want to upload the file
You will have to wait for the file to finish uploading
Step 6. Refresh the public_html folder
Return to the File Manager window and click on public_html folder to refresh it so you can see the new contents.
You should now be able to see the zip file you uploaded in the public_html folder
Step 7. Extract the file
- Select the file
- Hit Extract
The job is not yet done. You now have a new public_html folder inside the existing public_html folder. In other words, the files are not where they should be.
Step 7. Move the files to the public_html folder
The files were extracted to a new public_html folder inside the existing public_html folder. Your website now exists – but to see it you must enter /public_html in the browsers address bar after your domain name.
To fix it you need to move the files to where they belong…the root public_html folder
- Select the new public_html folder – you should now see all the files in there
- Hit Select All(as before) to select all the files
- Click and drag the files into the correct folder
Step 8. Visit your website to confirm it worked
Your website is now restored and should work exactly as before.
- Before you install anything or update anything on WordPress – ALWAYS run a backup
- Two things need to be backed up: 1. your database (which contains all your content and settings) and 2 the files (which make up your website). Of these two, the database is the most important, as it’s the most difficult to repair
- Store your backup zip files someplace safe – because you never know when you might need them
- Restoring your site to a previous version is done via cpanel.
- The Online Backup for WordPress Plugin makes it fast and easy to do backups – and you can even schedule them automatically.
This is the most important lesson that we teach on our WordPress course.
Don’t forget to back up your website!
Got a better way to do it? or a question? Please let me know in the comments below.