There’s nothing more heartbreaking for a website owner than having put dozens or hundreds of hours of work into perfecting their WordPress site, only to have it trashed by hackers, hardware failure, or a simple administrative mistake.
WordPress is enormously popular, with good reason, but as with any complex software it’s susceptible to malicious individuals and user errors. Your WordPress database and other assets should always be backed up so that, in the event of a catastrophe, you can simply reinstall, import your data, and be back where you were before disaster struck.
Most decent hosting companies will keep a backup for you, but as the saying goes, if your data doesn’t exist in three places, it doesn’t exist at all. Having a backup available that you fully control can be very useful.
There are many services and extensions that will help you with backing-up, but we’re going to take a look at how to back up to Amazon’s Simple Storage Service (S3).
S3 is one of Amazon’s suite of web services (AWS). You can think of it as a hard drive in the cloud — Amazon refers to each S3 instance as a bucket, and you can throw whatever data you like into that bucket.
First a word about cost, AWS isn’t free (unless you qualify for the free tier), but it is very cheap for the amounts of data we’re dealing with here. If you want to know exactly how much you’ll be paying, take a look at the price guide and the Simple Monthly Calculator. Unless your site is huge, the costs will be negligible.
We’re going to assume you already have an AWS account. If you don’t, go to AWS and create one.
BackWPup is a great WordPress plugin that has all the features you need for backing up your site, including the ability to easily configure it to transfer data to an S3 bucket.
Log Into AWS and Create A Bucket
Once you have an account, go to the AWS Console and choose S3 from the list of services. You’ll be presented with a console that looks like this.
Click the ‘Create bucket’ button in the top left, and give your new bucket a name. This is where your backups will be stored. You can create folders within the bucket if you want, but it’s not necessary.
You can also choose which part of the world you want your data stored in. There’s a slight differential in cost between areas, with Europe being a little more expensive.
Find Your AWS Identification Tokens
AWS uses an Access Key ID and a Secret Access Key to control access to the service by applications. Go to the Security Credentials page (you can click on the account name in the top right of the console to navigate there).
Make a note of the Access Key ID and the Secret Access Key or just copy and paste it when you get to section below. Keep this information safe. If others have access to it, they will be able to delete or alter your backups.
Create A Backup Job and Authenticate BackWPup
Open your WordPress dashboard and navigate to the BackWPup tab. Click the button next to the title to create a new backup job and give it a name. Here you can choose what to back up. We’d advise that you backup everything, although you can be selective if your host has strict bandwidth limitations.
In the Job Type dialogue at the top left, check “Database Backup” and “File Backup”.
Next, scroll down the page to the S3 section.
Enter the Access Key ID and Secret Key ID you found in the last section. If all is well, WordPress will connect to your AWS account and the bucket you created earlier will appear in the drop-down list. You can also create other buckets from here.
Choose how many backups you want to keep in your S3 bucket; WordPress will delete the oldest. We suggest you keep at least a couple of months of backups.
Once you’re done, scroll back up to the top of the page and click “Save Changes”
Test Your Backup Job
You should always make sure everything is running smoothly. Once you have set up the back-up job, click on the “Jobs” menu item under BackWPup in the dashboard menu and select “Run Now” next to the job you’ve just created.
WordPress will display a console where you can watch your backup as it happens and check for errors.
If the process completes without errors, head over to your AWS console and look at your bucket. You will see a new file has appeared — you might need to refresh.
Congratulations! You’ve made your first backup to S3 and your files are safe and sound in the cloud.
Create A Backup Schedule
Now you know your backup is working, you need to schedule it so that you don’t have launch it manually. Go back to the BackWPup job page, click edit just as you would with a blog post, and set up some times in the “Job Schedule” box at the top right of the page. Be sure to click “Save Changes” when you’re done.
Verify Your Backup
As a final step to make sure your data is secure, you should ensure that nothing is happening in the process to make your backups faulty. You don’t want to think that you have secure backups only to discover that they are useless when the time comes to restore them.
The best way to do this is to run through the restoration process (which we’ll show your below) to ensure that the site can be recreated reliably. Obviously, it’s not a good idea to do this on your production site, but it can be done on a locally-hosted WordPress installation, using a temporary Amazon EC2 instance, or on a subdomain of your main site (probably best because it tests the whole process, including the hosting).
You should verify your backups regularly.
Restoring Your Site
Restoring a site is a little more complex than backing it up, but it’s nothing that a competent WordPress user will have any problems with. The process is excellently explained here.