Experts insights

Today is World Backup Day

Today is World Backup Day (Yay!). Happy World Backup Day. Now, if you haven’t backed up your smartphone and computer yet, go do that now. We’ll wait for you here. Okay, got it? Cool.

Now, just like you back up your personal data and your company’s data in case of fire, earthquake, power failure, alien invasion, etc., remember that backing up your website is just as important. It’s a dangerous internet out there. Just think of the number of hours you’ve spent on your site so far and then think of all of that work being wiped away because you didn’t make a backup.

With a Simple Hosting instance at Gandi, you can create backups with our free snapshots feature. But first, just in case you were wondering what kind of dangers are out there …

What’s the worst that could happen

Just in case you still don’t want to take backing up your site seriously, let’s look at some of the worst-case scenarios.

Compromised CMS

Of course, Simple Hosting instances are by and far used to host CMSes (Content Management System, like WordPress). And you just need to relax your guard for one software update and you could wind up with malicious code worming its way into the core code of your CMS software. At which point it’s better just to wipe the whole thing and start over from scratch. Of course, that becomes a lot more painful if you don’t have an un-compromised backup to restore from.

CMS Update Gone Wrong

On the other hand, even when you’re on top of CMS updates, things can sometimes go awry. Maybe you have a custom theme that suddenly breaks after doing an update, incompatible versions, or a connection issue mid-update.

Accidental Deletion of Files

All it could take is a sticky delete key and your whole site would be gone. But, more realistically, sometimes you think what you’re deleting isn’t important or that you’ll never need it again, or it just ends up being something other than what you thought it was.

Missed Renewal

We don’t doubt you’re on top of your renewals (psst you could even try activating auto-renew), but on the off-chance you happen to miss the expiration date of your instance, you could end up losing your data. We warn you before the expiration date and you still have two weeks after expiration to renew, but we all know: stuff happens.

Total collapse of society as we know it

You’ll definitely want to minimize downtime when society invariably devolves into Mad Max-style anarchy. You’ll thank us when your blog post about picking through the rubble goes viral.

How you can backup

Now that you’re on board with the idea, let’s look at how you can backup your site using snapshots on a Simple Hosting instance.

To begin with, always remember the backup mantra: 3-2-1:

3 backups
2 mediums
1 off-site

If you follow the 3-2-1 mantra, you’ll be sheltered even from the most catastrophic calamities that could befall your site.

To activate snapshots on your instance, click the Activate link next to Snapshots (in the upper-right corner) from the control panel page of your instance.

A snapshot takes a picture of your instance’s disk at a given time, so you would use this to create a backup of your files.

More than likely, you’ll need to back up your instance’s databases as well. If you’re using a CMS, that will be the case. Your database is where the majority of your content is stored.

Snapshots create a total of four images of your disk at four separate times: one snapshot of yesterday’s content, one of the day before yesterday, one of last week, and one last month. They will appear in your instance as a “snapshot” directory in your root (/) directory.

That covers your files. You can schedule backups of your database using a tool built-in to your Simple Hosting instance called anacron. This will then create a “dump” of your database that will be included in your snapshot.

We’ll go over setting that up for a MySQL database (the most common database) via sFTP. You should start by finding the anacrontab file. It should be at this address:


To do a backup of your databases, you need to perform an export using the command “mysqldump”.

To keep backups up-to-date, you need to create an anacron task that performs regular backups. Here is an example that you can add to your instance (If the user ‘root’ does not have a password, then you must delete {-pPASSWORD}, or delete the brackets {} and indicate the password of your ‘root‘ user after ‘-p‘:

@daily 0 mysql_backup mkdir -p /srv/data/tmp/mysql_backup ; mysqldump -u root {-pPASSWORD} --all-databases | /bin/gzip -9 > /srv/data/tmp/mysql_backup/`date '+%F'`.databases.sql.gz ; rm -f /srv/data/tmp/mysql_backup/`date '+%F' --date '1 week ago'`.databases.sql.gz

This particular line will export your database everyday, and will keep the last export for one week, which will line up perfectly with snapshots.

And keeping in mind the 3-2-1 rule, remember to periodically copy the snapshot directory from your instance’s root directory. If you do forget to renew your instance, like we mentioned above, and the whole thing ends up removed, your only backups will be the ones you downloaded to your local machine.

In case of emergency

If you should ever have to restore from your backups, then you would just need to put the contents of the directory corresponding to the most recent backup. The folder name will be a Unix timestamp like 1490741558.daily. The higher the number, the more recent the backup.

Copy the contents of the directory with the highest number into your lamp0 directory, delete ‘htdocs’ and then move ‘htdocs’ from the snapshot directory into the ‘vhosts’ directory.

First, remove the old database and create a new database with the same name.

Then, you can import your database dump into this new database using phpMyAdmin. To import it, click on the Import tab from the phpMyAdmin interface.

Happy World Backup Day

And that’s it. Now, regardless of what kind of chicanery takes place tomorrow, even if you wind up fooled, you won’t be a fool because you backed up your Simple Hosting instance. And the best part is, it’s free now that we’ve introduced free snapshots on Simple Hosting. Happy backing up!