If I’ve ever lost my website’s data, and I believe it’s happened at least once, it’s been so long that I’ve forgotten the details. In “the old days,” web developers would code everything locally as a static site, then upload the files to the server. So you always had a local backup of your website on your computer, which you keep backed up…right? But now with dynamic sites where most of your site is stored in a database, and a small amount is in your site’s home directory, backups are a little more complex. I’m going to lay out the benefits and different options below.
You Could Pay Someone Else for Backups
I did say “easy.” So you could have your host back up your data. They’re pretty good at this. But if something bad happened to that host, you could lose your site along with all those backups. I was never comfortable with this, so I’ve never used host-provided backups.
Or Easily Perform Website Backups Yourself
This approach always makes me feel good. Not just in a control freak type of way, but it’s always nice to know exactly how important things work in case there’s a problem. It’s also a comfort to have insight into the reliability of backups.
I’ve always had a few different ways to back up data, but a recent article from my favorite host forced me to revisit and improve my methods. To sum up, you need multiple copies in multiple places. You have (1) your site itself, you may have (2) a local copy, but you also need (3) a backup stored away from the host and not in your home.
You Will Have to Pay for Backup Storage
Like in the old days, I do back up my sites to my local computer – database and all. But that’s more for convenience than disaster recovery. A local copy is basically free. Let’s take a look at offsite storage. As a note, this also applies to your home computer as well.
Easy offsite storage is an external drive you copy your data to, then immediately store offsite. External drives are inexpensive and easily stored. I recommend against storing stuff at your place of work. It’s best to store it elsewhere, such as a safe deposit box, or a trusted friend/family member’s house.
My favorite third-party storage is Backblaze ($60/year for my computer) and their B2 object storage service (Half a penny per GB per month…yes, less than a cent). You will most likely spend a lot less than my $10/month. This site alone is 228MB as of this writing, so a single backup costs a fraction of a cent. Read the last section for how my costs add up.
How to Back Up Your Website Data Easily
I said that having your host do this is easy, but doing it yourself can also be very easy. Backblaze B2 makes it easy to set up a bucket (make sure it’s private) and then create an Application Key (make sure that key is just for the one bucket for your site…and copy/paste that key to a safe place).
Use a Plugin
For WordPress, I highly recommend All-in-One WP Migration by servmask. It’s a one-time $100 charge for the Backblaze B2 option. I’ve purchased various options, and they’ve even let me trade one for another, plus let me test drive a third option just for fun and feedback. The support from Pim has been exemplary. With this plugin, I tell it my B2 ID and Key, plus bucket name and it’s ready to go. All that’s left is to set up a backup schedule. More on that later.
Clone via Command Line
Thanks to the Vultr article I mentioned earlier, I learned about rclone. It’s free, and oh-my-gosh, it’s a totally easy way to backup my website! With a B2 bucket, all I need is a simple rclone.conf configuration file in my server home directory’s .config/rclone/ folder. The conf file only needs these lines:
[remote] type = b2 account = KEY_ID (put yours here) key = KEY (put yours here) hard_delete = true
“remote” is the name of the configuration your rclone command needs to reference:
rclone -v --fast-list --transfers 32 sync /home remote:BUCKET/May
-v is verbose so I can see what’s happening. –fast-list makes a larger file list so it doesn’t have to keep re-scanning your directory. –transfers is how many parallel transfers are running (B2 can easy handle 32). sync is the directive, as you can also ‘ls’ files, etc. /home is where all my site files are (actually a subdirectory, but I want all my home directory files as well). And the remote part is the name from the config file, plus the endpoint where all the files go. I have a ‘May’ folder in case I want to keep old mirrors of my files.
An Easy Backup Strategy
Earlier, I said my storage space is about $10/month. Then how does a penny-per-month backup add up so fast? First of all, I backup 25-30 sites to B2. That /home directory from earlier is about 24GB. I also keep the previous 50 daily backups in case I have to roll back the site for any reason. It may be a bad design change, a hacked site (hasn’t happened in a very long time), or I just want to reference old data in a sandbox. Doing the math (24GB x 50), I have 1200GB of data backed up from just one server. At .5¢/GB/month, that’s $6 per month. The rest comes from other servers I back up. As I’ve just started using rclone, that will add an additional 12¢ per backup per month.
I already mentioned that I have daily backups of my sites. These are all automated from my All-in-One WP Migration plugin. It packages the site files and database into a single .wpress file. Super easy, and super reliable. I actually don’t schedule them in the plugin. Rather, I run them from a wp-cli command via cron. If you’re keeping score, that’s my second copy of website data.
My third copy of website data was on my home computer. Once a month, I would remotely run a wp-cli command to dump the database into the user’s home directory, then rsync (similar to rclone) all of that to my home computer. Technically that’s also a fourth copy because my home computer backs up to Backblaze in that $60/year plan.
I’m going to replace that process with rclone and run it weekly. As it’s rclone, it’s a single backup, but I plan to keep the previous month or two on B2. After all, it’s just 12 cents per month for each monthly folder.