Backup Strategy

We have all lost data at some point. Whether it is an accidental fat fingered rm -r or hardware failure or something else, it sucks. Having a decent backup solution helps ease the pain and hassle.

In a previous life, when I used an Apple machine, I had a hard drive set up with Time Machine for local backups and I used Backblaze for off site storage. Now that I am back on a Linux machine, a different approach is used.

The main backups are handled by rsnapshot which backs up my home directory to a hard drive that is always plugged in whenever I am connected to my dock. The config file specifices several levels and retention amounts:

  • Hourly: 24 backups (assuming the computer is on) per day
  • Daily: 7 backups, one for every day of the week
  • Weekly: 4 backup to correspond to 4 weeks a month
  • Monthly: 12 a year, once a month
  • Yearly: just the one

These are kicked off by systemd services and timers. The clever bit is only needing the one service and timer and using arguments to determine the backup level. Running systemctl --user enable --now backup@hourly.timer sets up the hourly backup, systemctl --user enable --now backup@daily.timer sets up the daily and so on. The unit files are stored in ~/.config/systemd/user/ so as to not need to mess around with root permissions or setting up another user. I only care about my home directory, if the system itself becomes bad, I can easily blow it away and reinstall then pull from my backups.

The backup drives are many and redundant. The hotstore drive I have plugged in all the time, I have 2 coldstore drives which are kept in a Pelican 1200 case and I have just provisioned one offsite drive, cunningly named for being stored outside of my home so that in the event of a fire or what have you, I at least have a semi-up to date copy of my stuff.

Of course, having data encrypted at rest is always a good idea. All of the drives are set up using my encryption script which uses some sensible defaults to help protect my data.

Data replication is handled by a script called (funnily enough) syncstuff which is basically a wrapper around rsync. Takes a while to do the job but I am happiest with that way of doing it. This also syncs up my documents and mail to the various drives, as well as a microsd kept on a necklace most of the time.

Date Tags backups