We want you to try and conceptualize what we’re doing in this lesson as what you could call “Data Portability”. Backing up and restoring your site is very important, but we’re going to try and drive home the point that these things are possible because of the digital, infinitely replicable nature of data. You will backup, migrate, restore, break, restore, and other stuff to your site as a way of understanding that you can do whatever you want with the package of data that is your site.

Backing up WordPress

With each update of WordPress and its plugins, there are many bug fixes that benefit the running of your site, however, the more variables you have, you risk of running into incompatibilities between your site’s WordPress installation and your third-party plugins, making your site pop up with a nasty error message.

In addition, misplacing files, editing the wrong ones, messing with the databases incorrectly, or changing some settings in wp-admin could run your site into the ground, making it unusable for any visitors or yourself.

Breaking your site is just something that happens sometimes, so you need to learn how to back up your own site files and restore them so you never have to work from scratch. It is important to have your site up and running as fast as possible, because few new viewers ever return to a site that didn’t catch their attention the first time.

Your web host is another potential point of failure. By storing/hosting your website files on your web host, you are trusting them to keep your website files safe and secure. But everyone makes mistakes. Your web server can go down. You take a risk by having someone else handle your website files. We need to take matters into our own hands and ensure that we are prepared for any bad event.

What Needs To Be Backed Up?

There are two parts to backing up your WordPress site: Database (Content) and Files (Structure, Rules). You need to back up the entire site, and you need to back up your WordPress database to ensure the site can be fixed when an error occurs.

Your WordPress site consists of the following

  1. The WordPress Core Installation
  2. WordPress Plugins (/wp-content/plugins/)
  3. WordPress Themes (/wp-content/themes/)
  4. Images and Files (/wp-content/uploads/)
  5. JavaScript and PHP scripts, and other code files
  6. Additional Files and Static Web Pages

As you already know from the first half of the class, all of these are used in various combinations to generate your website. The database contains your posts and a lot of data generated on your site, but it does not include the above elements that all come together to create the look and information on your site. These need to be saved.

Backing up Site Files

We have quite a few options when it comes to how we want to backup and restore our websites. This section will walk us through using the plugin that we recommend. In the toggles you will find alternate methods that are definitely worth checking out because they offer their own unique benefits.

Backup Plugin: UpdraftPlus

We’ve evaluated a lot of backup plugins, but we feel that Updraft Plus is a solid plugin. It is easy to use and has nice features. Go ahead and install and activate Updraft Plus.

By default, UpdraftPlus does complete backups, meaning it backs up your database, themes, plugins, and media uploads. Under Settings, you can change whether it backs up your plugins, themes, and uploads. We suggest to leave it how it is and back up these folders.

One downside to UpdraftPlus is that it does not backup a copy of the core WordPress files. The good news is: you can always redownload these from WordPress.org again (the same WordPress files you downloaded to install WordPress manually).

Scheduling

An important feature to note is that UpdraftPlus allows for scheduling. By default, it’s set to do backups of the database and files only manually. When determining how what kinds of backups you want to schedule, you need to consider a few things.

Frequency of Changing Content

Just how often is this site being updated? If it’s a blog or something that’s often publishing new content, then you’ll probably want to backup more often. If it’s a static site, then you probably don’t need to schedule a regular backup and can get by with just a manual backup whenever you do an overhaul.

Scheduling Walk-Through

Depending on your website’s needs, you may need to change the scheduling of your backups. Go to your installed plugins and under UpdraftPlus hit Settings. At the main page, hit the Settings tab.

schedule1

Under Confige Backup Contents and Schedule, you can see the intervals that are set for the File backup and Database backup (by default they are set to manual). To the right, you will also see the number of backups that will be stored/retained of each backup type. Depending on your needs, you can set up a schedule for automatic backups for each backup type. For example, your could set the file backup to once a week and database backup to daily.

schedule2

In the Include in files backup section, you can select or deselect what files will be included in the files backup portion.

If you have made any changes, make sure to scroll to the bottom and hit Save Changes.

Backup File Storage

By default, when the plugin runs a backup, it will create multiple zip archives in a directory called updraft in your wp-content folder for that WordPress instance. Cool beans, you think. They’re right there when I need them. Wrong! What if the server goes down? What if there’s a fire at the data center? What if the police or an intelligence agency come by and rip the server out of the wall? You’d lose your files and data! Backups need to be stored somewhere else.

You need to pull the backup files off your server and deposit them somewhere safe. Options for this include: an external hard drive, the hard drive of the main office computer, CDs, flash drives, cloud storage like Google Drive, Box, or Dropbox. At any rate, you should have a discussion with your org about how they want to keep copies of their site.

Lucky for us, UpdraftPlus includes remote storage, meaning you can enable it to upload copies of your backup files to many cloud storage services.

Remote Storage

This is an extremely important feature. Storing backup files in multiple places helps us ensure that we will be able to retrieve our files when we need to, even when things go south.

For each cloud storage option (Dropbox, Google Drive, etc.) there is a different process to set it up. For this walk through, we will be using Dropbox as it is relatively easy to set up.

In the UpdraftPlus settings area, go to the Settings tab.

Under the Copying Your Backup To Remote Storage section, choose the remote storage service you want to use. For this example, choose Dropbox.

backup1

Next, scroll to the bottom and hit Save Changes.

Go back to the Settings tab under the remote storage area. We need to authenticate UpdraftPlus with Dropbox. Follow the link that is provided (mine looks slightly different as I already authenticated with Dropbox).

backup2

It will take you to Dropbox where you will need to sign in and verify the authentication process. Once you have done that, you are finished. To double check, go back to UpdraftPlus to the remote storage section. If it says, “You appear to be already authenticated”, you did this correctly.

Now when you backup your website (either manually or scheduled), it will also upload a copy of the backup to your cloud storage, in this case Dropbox.

Our Recommendation

Since we’re dealing with dummy accounts and development playgrounds, you should set your backups to manual only.

Other Methods

Expand the below sections for other backup methods.

Backup Plugin: Backup WordPress

We’ve evaluated a lot of backup plugins, but we feel that “BackupWordPress ” is a very solid program. It is easy to use and has some nice features. So go ahead and install and activate BackupWordPress.

The plugin has three different types of backup. What they do is fairly self evident:

  1. Database Only
  2. Files Only
  3. Complete

An important feature to note is that it allows for scheduling. By default, it’s set to do a daily database backup and a complete weekly. When determining how what kinds of backups you want to schedule, you need to consider a few things.

Frequency of Changing Content

Just how often is this site being updated? If it’s a blog or something that’s often publishing new content, then you’ll probably want to backup more often. If it’s a static site, then you probably don’t need to schedule a regular backup and can get by with just a manual backup whenever you do an overhaul.

What to Do with Backup Files

When the plugin runs a backup, it will create a zip archive in your root directory. Cool beans, you think. They’re right there when I need them. Wrong! What if the server goes down? What if there’s a fire at the data center? What if the police or an intelligence agency come by and rip the server out of the wall? You’d lose your files and data! Backups need to be stored somewhere else.

You need to pull the backup files off your server and deposit them somewhere safe. Options for this include: an external hard drive, the hard drive of the main office computer, CDs, flash drives, cloud storage like Google Drive, Box, or Dropbox. At any rate, you should have a discussion with your org about how they want to keep copies of their site.

Scheduling with BackupWordPress Plugin

The plugin has a scheduling feature that allows you to set up several different backups. By default it has two set up: A daily database-only and a weekly complete.

backup-w--9

  • Select ‘Both Database and files’, schedule for ‘Manual Only’, set to ’10’ for the number of backups, enter your email, and ‘Update’

backup-w--10

  • Select ‘+add schedule’ in the header again
  • Set a schedule for automatic updates for both files and the database separately
  • (Recommended: Daily as a maximum for the Database, Weekly as a maximum for Files)

Congratulations! You now have your WordPress installation backed up, either on your own computer, your email, your website’s root directory, or your WordPress installation’s /wp-content/c4ca4238a0-backups/.

Full Domain Backup with cPanel

This will create a backup of your entire domain. i.e. every file and database you have.

  • Login to your domain’s cPanel (www.yourdomain.org/cpanel)
  • Navigate to ‘Backups’

backup-w--1

  • Click ‘Download or Generate a Full Website Backup’ / ‘Download a Home Directory Backup’ (for Files only) or ‘Download a MySQL Database Backup’ (for Database only)

backup-w--2

  • This will create a download link to a compressed folder of your entire domain’s files and databases

backup-w--3

Selective backups

This will create a backup of your WordPress installation and WordPress database

WordPress Files:

In your CPanel File Manager, create a zip/compress file of your WordPress instance’s directory. Download a copy of this.

WordPress Database:

In cPanel, navigate to phpMyAdmin

backup-w--4

 

Go to the Databases tab. Select the database of your WordPress installation

backup-w--5

Select Export, then generate an SQL export

backup-w--6

Export via phpMyAdmin

Make sure to hit Go at the bottom to export the SQL database.

Restoration

What’s the use of a backup if you don’t know how to restore from it?

If you used UpdraftPlus to backup your WordPress site, you will have multiple zip archive located in your WordPress instance’s wp-content/updraft folder. You will also have zip archives of your backup on your remote storage if you set it up.

UpdraftPlus gives a lot of flexibility in what we want to backup and subsequently, what parts of our website we want to restore. You should have a zip archive for each of these if you did a complete backup: Database, Plugins, Themes, Uploads, and Other.

With UpdraftPlus, you can restore as much or as little as you want. Say you only want to restore your website’s database. Well, you would only upload your backed up database and restore based off of that. It would not restore your plugins, themes, uploads, and other things.

You also have the ability to restore from backups stored on your hosting storage. Think of this as a backup option to files that are stored on remote storage.

Restoration Walk Through

Before you can restore your WordPress site, you will have needed to back it up already. You can check this by looking at Last backup job run: in the Current Status tab in UpdraftPlus.

If you have already done a backup, hit Restore.

restore1

We have two options for restoring our WordPress site. We can either use files that UpdraftPlus can “see” (files that are either stored on the web hosting storage or remote storage) or upload the individual zip archives from a backup.

You can hit Rescan local folder for new backup sets or Rescan remote storage to refresh backup files that UpdraftPlus can “see”. If UpdraftPlus can see any backup files in will list them by backup date, show what backup zip archives are available, and lets you Restore from there.

restore5

If you want to be selective in the different parts of your WordPress site you want to backup or use different backup files from what UpdraftPlus can see, you can upload individual zip archives using Upload backup files.

restore2

In the image above, I uploaded the database zip archive from a backup. Notice that the other backup parts (Plugins, themes, etc.) aren’t there. If I hit Restore, UpdraftPlus would restore our site based off what backup data was uploaded, in this case, only the database. In this way, we can be selective in how we restore our WordPress websites.

Pro-Tip: If you still have issues with ‘Page not found’ errors after restoring, in WP-Admin, under Settings > Permalinks, change your permalink type, ‘Save Changes’, set it back, ‘Save Changes’. Ta-Da!

Homework Assignment

Backup Your Site

This assignment will demonstrate that you can perform a site restoration from a database backup. The steps involved are deliberate as they prove that you indeed did the work, so please follow them exactly.

We are going to be using your WordPress site yourdomain/wplesson4 for this assignment.

Part 1

  1. Set your front page to be your blog
  2. Make a new post. Make sure this post has a (small) image in it.
  3. Make a full backup using UpdraftPlus.
  4. Make a new post, this time with a different image.
  5. Take a screenshot proving that you made this new post. You can take screenshot of your front page or of your post manager
  6. Restore your site using your backed up database using UpdraftPlus (use the database archive it created in the full backup).

The last post you made will be gone since it wasn’t backed up in the database you restore from.

Part 2

Sometimes plugins fail. We do not want to be completely dependent on plugins that are developed by others. For Part 2, we are going to manually backup the database (not using UpdraftPlus).

Following the instruction under Selective Manual Backups in this lesson, export your WordPress site’s database. This will be in the form of a .sql file.

This may seem out of place in this lesson/homework, but it is important for the next lesson.

Submission

Email wordpress@labs.everettprogram.org the following:

  • Email subject line in the following format: HW #5 Firstname Lastname
  • The web address of your WordPress instance yourdomain/wplesson4
  • Attach the screenshot you took proving that you made a new post.
  • Attach the .sql database you manually backed up in Part 2. Make sure the file ends in .sql.