One of the greatest discoveries I’ve made after switching to the Linux galaxy is, without any doubt, the fantastic Restic; a backup tool that deserves to be better known and more widely used.
I usually describe Restic to my friends still in the Apple galaxy as follows:
It’s like Time Machine, but on the command line.
Of course, all reductions are dangerous, but the phrase above captures the gist of it.
To install, it’s just like any other tool built with Go: download the latest release, copy it into your
PATH, and you’re done. Binaries built with Go are usually self-contained, another of the greatest features of this wonderful programming language.
Well, technically you don’t even need to do the above; you can also use it as a container, with Docker or Podman:
$ podman pull restic/restic
Once you have the program in your path or on your local container image registry, you must create a repository, and for that you need a location (either online, on a shared disk, or on your NAS) for Restic to save backups into.
Once that’s done, you can start backing things up:
$ restic --repo /somewhere/repo init
$ restic --repo /somewhere/repo backup ~/Documents
After that, the
snapshots subcommand will show the history of your backups:
$ restic --repository /somewhere/repo snapshots
And as expected, the
restic restore command… well, restores a particular snapshot into any path you specify.
(There’s also an
-r argument instead of
--repo, of course.)
You can store your repositories in a variety of locations: in a hard disk next to your computer, but also off-site: on an S3 bucket, for example, and in many other locations.
Restic is compatible with Windows, Mac, Linux, and even BSD. Your backups are encrypted using your password (which means that losing it will be a catastrophic event) and only stores the changes between backups, making it really efficient. Oh, and it’s open-source, it can self-update, and even provide autocompletion information for various shells.
I discovered Restic at VSHN, because my colleagues used it to create K8up, a Kubernetes operator (also written in Go) that helps DevOps engineers backup the contents of their clusters. K8up effectively “wraps” Restic and uses it to drive the backup process; backup repositories created by K8up are actually Restic repositories.
I have been backing up my computers (Mac, Windows, and Linux) with Restic for the past 4 years, and seriously, I’m not switching away from it anytime soon.