Will's avatar

⬅️ See more posts

Borgtastic Backups

19 August 2024 (3 minute read)

🔮 This post is also available via Gemini.

technology selfhost

Restic has been my go-to backup tool for many years, and I’ve used it for a wide range of workloads – including for managing filesystem, Postgres, Photoprism and Vaultwarden backups. At the point I was researching suitable backup options for these cases, and considering my personal requirements, I was often stumbling upon discussions comparing Restic to a similar tool – Borg backup – but I eventually settled on using Restic myself, due to its flexibility and the amount of data (measured in terabytes) I intended to backup.

In addition to the handy utilities and ease of backup encryption, what drew me to these two tools in particular was their ability to easily provide incremental backups and snapshots – something I wasn’t sure other tools, such as Rclone, could do.

Borg is itself not limited in terms of the size of the archives it backs-up (in fact, it is often more performant than Restic in terms of compression and computation), but the deployment of Borg remote targets was such that the cost of backing-up large volumes of data would be prohibitively expensive. Restic, on the other hand, does not require any remote processing and can directly work with low-cost object storage providers, such as Backblaze B2. At the time, workflows along the lines of Rcloning a local Borg repo to cheap object storage didn’t cross my mind.

Either way, more recently, I’ve been swept up in further online discussions comparing the two tools. One particular thread I saw (I don’t remember where) mentioned a tool called Borgmatic; not something I had heard of before. After some research, the strengths of this system quickly became apparent.

In its simplest form Borgmatic is a collection of utilities for Borg backup, exposed primarily via a handy and easy-to-craft configuration file. A single such file can be used to define multiple backup targets and repositories, immediately removing some of the pain in complex commands and backup scripts that reference borg commands directly.

Personally, one of my favourite features is Borgmatic’s ability to directly backup databases. Particularly useful to me is that MongoDB and PostgreSQL database backups are achievable with only a few configuration lines, with the appropriately relevant dump commands being used behind the scenes to ensure data correctness. Borgmatic can also automatically restore databases if needed.

Other useful features are its built-in checks and monitoring. I schedule manual backup “checks” (in addition to tests) on a semi-regular basis, but being able to skip the “are things actually be being backed-up” segment of this would be welcomed.

Borgmatic’s “official” Docker image makes deployment super simple, and also includes the ability to specify a cron-based backup schedule using environment variables.

Along with the reduced overheads in managing Borgmatic-based backups (try saying that ten times quickly), and given the added ease of Borg-compatible services such as BorgBase (which also include their own monitoring), I plan to complete migrating some backups to this new system – particularly databases, which are less about data volume (in my cases) and more about fiddly configuration, to which Borgmatic is highly suited to solve.

✉️ You can reply to this post via email.

📲 Subscribe to updates

If you would like to read more posts like this, then you can subscribe via RSS.