adikos.net

Backup Thoughts

This started as a little document to get down my thoughts, but I figured I'd Markdownize it and make it into a blog post, where it can be not only a reference for me, but also for everyone else!

I like to think I have a pretty decent backup system in place. I have a 2Tb USB-C HDD that hangs out in my office and effectively mirrors my laptop. I also have a lot of older material on it; my previous laptop, as well as my desktop from years past, makes up a stratum or two on there. And I try to remember to do a full backup once a month or so, but I don't always remember, which is not great. I like to know my files are safe, just in case my laptop blows up or something. Putting /home on its own partition is always a good practice, so then / (your system files, the OS, &c.) can be wiped and reinstalled without touching your important files. But that's not enough, and that's where backups come into play.

Backing up to a physical hard drive is great. I am looking into getting a safe to put important files into, and probably also that HDD, because why not? But why not add another level of redundancy and have another mirror of your files? If you are wanting a second mirror, or maybe want to do something other than a physical HDD, then hopefully this post will be helpful. I originally planned on setting up a cloud backup service, but that did not end well. I ended up just increasing the space on this VPS to allow for backups.

This tutorial is heavily based on, and builds upon, this tutorial, which is a great starting point. However, at least in my use case, I found that there are some corrigenda within though. I would recommend reading this alongside the linked tutorial, since it includes some fixes, and I will try not to duplicate that tutorial too much as a result.

This post assumes that you have access to either a remote server (VPS, virtual private server, vel sim.), or you can do this on a Raspberry Pi or something if you want. I'm also assuming you're running some flavor of Linux on your host system; if you have Windows, then your backup solution is going to look different. Unless, of course, you are using Cygwin or something similar, then cool. We are also assuming you have the rsync ("remote sync") program installed.

here is the rough process:

Once you've set up public key authentication for your "backup" user, and have confirmed that you can log in with this user, then we'll set up the encrypted backup itself.

That step will take a little while. Once that's done:

Once the encrypted "container" file is created, we'll create a partition within it:

Now your encrypted partition will be mounted at /mnt/remote-backup, and you can rsync to it all you want! Look at the linked tutorial above for suggestions on calling rsync. Throw files at the encrypted backup to your heart's content; it will function like just another folder on your computer, but in fact we're talking to a remote computer over sshfs.

When you're done chucking files at the encrypted backup:

In future, to mount everything:

Just use the unmount sequence of commands to close it out.

I just set up shell scripts (.sh files) automating the mount/unmount process, so it should be pretty easy to just chuck those into a file and run as needed.

I'm really pleased with this setup, especially since I can do encrypted backups with nothing but standard shell commands and rsync. I hope this is useful for you as well. I know it may be a little niche, but if you have a Linux setup at home and a Linux server to play around with, it's well worth trying it out. Thank you for reading, friends <3