Sub topic 2
restic or Borg: how to choose
This chapter assumes you know the Linux command line, can log in over SSH with keys, and understand the 3-2-1 rule and the RPO and RTO goals from the previous chapter. It does not teach either tool in detail. The goal is a decision you can defend, so the later chapters can follow one tool or show both side by side.
Why this is a real decision
restic and BorgBackup (Borg) solve the same problem in a similar way. Both split files into chunks, deduplicate the chunks, encrypt them on the client, and store the result in a repository. Both give you point-in-time snapshots (Borg calls them archives), a mount command for browsing, and an integrity check.
The differences are in where the repository can live, which platforms run the client, how concurrent access works, and how much tooling you get around the core program. Those differences decide which tool causes less friction on your servers.
The comparison
The table reflects restic 0.16 and later and Borg 1.2 and 1.4. Borg 2.x is a different generation and is covered later in this chapter.
| Question | restic | Borg 1.x |
|---|---|---|
| Implementation | Go, one static binary | Python with C extensions, packaged as a binary or installed through your distribution |
| Client platforms | Linux, macOS, Windows, BSD | Linux, macOS, BSD. Windows only through WSL or Cygwin |
| Remote storage | Local, SFTP, REST server, S3-compatible, Azure, Google Cloud Storage, Backblaze B2, and anything rclone supports | Local path or SSH. The remote host must run Borg |
| Object storage | Native | Not native. Needs a workaround such as rclone |
| Several clients, one repository | Supported. Writers take non-exclusive locks | One writer at a time. Sharing a repository between machines is discouraged |
| Compression | Yes, in repository format v2 (restic 0.14 and later) | Yes: lz4, zstd, zlib, lzma, selectable per backup |
| Encryption | Always on. AES-256 with Poly1305-AES authentication | Optional. AES-256 with HMAC-SHA256 or BLAKE2b |
| Configuration | Environment variables and command-line flags | Environment variables and flags |
| Wrapper tools | resticprofile and others | borgmatic, widely used |
Storage backend
This is the most common deciding factor. If you want backups in S3, Backblaze B2, Azure or Google Cloud Storage without running any software on the storage side, restic supports that directly.
Borg 1.x needs a Borg process on the other end of the SSH connection. The client runs borg serve on the remote host and talks to it over the SSH pipe. This gives good performance and lets you restrict a client to one repository with an SSH forced command. It also means you need a host you can install Borg on, or a provider that offers Borg hosting.
If you already have such a host, for example a second server or a storage box, Borg over SSH works well. Restic also works there, over plain SFTP, and the remote side needs nothing but an SSH account.
Concurrency and shared repositories
Restic repositories accept several clients at once. Ten servers can back up to the same repository. They share deduplication, and restic's lock files keep them from damaging each other. Operations that remove data, such as forget --prune, take an exclusive lock and block other writers while they run.
Borg expects a single client per repository. It keeps a local cache of the repository's chunk index and checks it against the repository, so a repository used from several machines forces cache rebuilds. The usual Borg layout is one repository per server. You lose deduplication across servers, but the failure domains are cleaner.
Speed and resource use
Borg usually uses less memory and writes less data for a large set of unchanged files. It also lets you pick the compression algorithm per run. Restic is simple to deploy, but its memory use grows with repository size, and a large repository can need several gigabytes of RAM for pruning. Test with data close to your real data, because results vary with file count, file size and storage latency.
Workflow and tooling
Restic is a single binary with a settings model built on environment variables. Copying it onto a new server is trivial, and the same binary works on laptops and servers.
Borg has a more mature ecosystem for scheduled, declarative backups. borgmatic reads one YAML file and handles create, prune, check and database dumps. Restic has similar wrappers, but they are less standardized.
Borg 2 and the future
Borg 2 changes the repository format and adds a storage layer that can reach more backends, including object storage. At the time of writing it is still in beta, and it cannot read Borg 1.x repositories without a migration. Do not use a beta for the only copy of production backups. Choose based on Borg 1.2 or later, and plan a migration later if you want the new features.
A decision flow
The questions below are ordered by how often each one settles the choice in practice.
Checking what you have
Before you commit, check which version of each tool your distribution ships. Distribution packages are often older than the upstream releases, and several features in this chapter depend on version numbers.
restic version
borg --versionIf the packaged restic is older than 0.14, you will not get compression. If you need a newer one, restic can replace itself with restic self-update, but only when it was installed as a standalone binary and not by your package manager.
Borg 1.2 introduced borg compact, which later chapters rely on. Borg 1.1 and earlier freed space during borg prune, so the commands differ between versions.
Matching the choice to your situation
These are typical situations and the choice that causes the least trouble.
- One small server, backing up to cloud object storage. Use restic. No software is needed on the storage side, and one binary does everything.
- A few servers, backing up to a storage host you run. Either works. If each server gets its own repository and you want declarative configuration, Borg with borgmatic is a good fit. If you want shared deduplication, use restic.
- Mixed fleet including Windows or macOS machines. Use restic, because the same tool and repository format cover every client.
- Large repository with limited RAM on the server. Test Borg first. Measure memory during backup and prune, not just during backup.
- Strict control over what a compromised client can do. Both tools offer protection. Borg has an append-only mode enforced by the SSH forced command, and restic has the same idea through the REST server's append-only option. Either way, a client that can only add data cannot delete old snapshots, and that limits what ransomware can destroy.
Common mistakes when choosing
- Choosing for the first backup instead of the restore. Both tools back up quickly. Compare how you will restore at 3 a.m. with one binary and a password file, and whether you will have that binary and the credentials at hand.
- Assuming Borg can write to S3. Borg 1.x cannot do this natively. Adding an rclone mount layer works but adds a failure point and hurts performance.
- Sharing one Borg repository between servers. It works until cache mismatches and lock contention appear. Use one repository per client.
- Skipping version pinning. An unattended upgrade that changes the repository format can leave older clients unable to read the data. Pin versions, or test upgrades on a copy.
- Treating the choice as permanent. Switching later means starting new repositories. Keep the old one until the new one passes a restore test and your retention period has run out.
What the rest of the tutorial does
The remaining chapters give both tools' commands next to each other, because the concepts are the same. Where the tools differ, such as restic's forget --prune against Borg's prune followed by compact, the text says which one it covers. You can follow only the tool you chose.
Exercise
You manage one server that must send backups to an S3-compatible bucket, and a second server whose backups must go to a Linux host you control over SSH. Both servers should be able to share deduplicated data in the future. Which tool do you choose, and what is the main reason?
Show answer
Choose restic. It writes to S3-compatible storage natively, while Borg 1.x cannot. It also supports several clients writing to one repository, which allows shared deduplication later. Borg would need an rclone workaround for S3, and it discourages sharing one repository between machines.
Exercise
A colleague wants to use Borg 2 because it supports more storage backends. What is the risk, and what do you recommend for a production server today?
Show answer
Borg 2 is still in beta and uses a repository format that Borg 1.x clients cannot read, so a bug or a format change could affect the only copy of your backups. Use a stable release, either Borg 1.2 or later or restic, for production. Test Borg 2 in a scratch repository and plan a migration once it is released as stable.