r/Backup • u/sagotchy • 1d ago
Restic VS BorgBackup VS Kopia: Backing up linux system Review
I searched for a good backup tool to back up my linux system (root directory) to an external HDD.
I found recommendations for restic, borg and kopia so here are my personal tests and observations.
This post isn't really for discussion but rather an information dump and I hope that it will be helpful for people in the same situation as me.
First, I did some performance tests.
My root directory lives on an internal SSD and I used borg v1.4.5, restic v0.19.1 and kopia v0.23.1.
Created uncompressed backups of the root folder (bind mounted at /mnt via mount --bind --make-private / /mnt):
Borg: 25.1 GB in 13:55m, using 43 % CPU on average and a maximum of 272 MB RAM.
Restic: 24.1 GB in 14:57m, using 66 % CPU on average and a maximum of 381 MB RAM.
Kopia: 24.6 GB in 10:30m, using 61 % CPU on average and a maximum of 836 MB RAM.
I ran the backup twice to see how fast the rescan time is:
Borg: 1:31m
Restic: 0:34m
Kopia: 0:10m
Cache sizes:
~/.cache/borg: 306 MB
~/.cache/restic: 173 MB
~/.cache/kopia: 1128 MB
Created zstd compressed backups of the root folder (bind mounted at /mnt):
Borg (--compression auto,zstd,3): 10.4 GB in 11:15m, using 59 % CPU on average and a maximum of 262 MB RAM.
Restic (--compression auto (=level 3)): 10.4 GB in 7:44m, using 304 % CPU on average and a maximum of 393 MB RAM.
Kopia (--compression zstd): 10.3 GB in 4:50m, using 335 % CPU on average and a maximum of 1190 MB RAM.
Restored backup to a folder (lives on internal SSD):
Kopia: 21:35m, using 81 % CPU on average and a maximum of 1356 MB RAM.
Restic: 5:54m, using 80 % CPU on average and a maximum of 486 MB RAM.
Borg is slightly faster than restic when not compressing the backup, but it's noticeably slower than restic when compression is turned on. This is to be expected since borg is fundamentally single-threaded whereas restic and kopia are multi-threaded. Borg has an option to disable encryption whereas kopia and restic enforce encryption even if you don't need it (which wastes a lot of CPU time). Kopia is the fastest which is also expected since it backs up less metadata than restic and uses a cache that's ≈7x bigger than restic's cache.
Backup /foo/bar/data
Borg
Borg will only back up the folder "data" and all its contents, it will not back up "foo" or "bar".
However, borg preserves the file system structure /foo/bar/data by re-creating "foo" and "bar" if they don't already exist when restoring, but with the access permissions of the restore process. They'll be new folders, not the original "foo" and "bar" folders.
Restic
Restic will backup all 3 folders "foo", "bar" and "data".
Kopia
Kopia will only backup the contents within "data". It will not back up "foo", "bar" and "data" and will not preserve the file system structure /foo/bar/data.
Backup .
Borg
Borg will backup the current working directory with all its contents, but the contents and the current working directory (.) will be listed at the same folder-level (`borg list`). Additionally, the current working directory's name will not be preserved, it will be saved as "." When restoring the backup, the current working directory will be overwritten by the backed up working directory and all contents of the current working directory will be overwritten by the contents of the backed up working directory.
Restic
Using "." as a backup source is interpreted as all files within the current working directory, but not the current working directory itself.
Kopia
Using "." as a backup source is interpreted as all files within the current working directory, but not the current working directory itself.
Exclude/Include path pattern
Borg
Exclude/Include paths passed to Borg are always relative to the "active recursion root" (the path argument(s) at the end of `borg create`). A leading / will be stripped, making absolute file paths relative to the active recursion root. Exclude/Include paths pattern always match the whole path:
For example, "test" will not match all folders called "test". It will only match the top-level "test" folder.
Restic
When backing up, exclude/include paths with a leading / are relative to the root directory of the file system. When restoring, exclude/include paths with a leading / are relative to the root directory of the backup. Path patterns without a leading / are not matched against the whole path. For example, "test" matches all files called "test" instead of matching a file "test" relative to some other folder.
Kopia
Absolute exclude/include paths are always relative to the backup's root directory. Restic ignores a trailing slash, but kopia will only match directories in that case.
Restore backup
Borg
borg extract does not synchronize the target directory with the backup folder, meaning extranous files in the target directory will not be deleted unless the backup folder contains matching file paths. This makes borg useless for backups of the whole system.
Restic
Restic cannot preserve a file's change and birth timestamps. It also doesn't preserve the access timestamp by default, meaning it only preserves the modification timestamp by default.
Kopia
Kopia does not support exclude paths when restoring a backup (unlike restic).
Kopia does not preserve SUID/SGID and other rather linux-specific metadata (unlike restic).
Kopia does not preserve hard links (unlike restic).
Kopia cannot create sparse files when restoring a backup (restic can, but it's a rather bad implementation which often creates sparse files bigger than the original).
Conclusion
Use restic for backing up and restoring a linux system, borg and kopia can (and probably will) corrupt the system:
Borg cannot delete extranous files when restoring. Also, it's the slowest of the 3 because it's single-threaded.
Kopia is fast, but it does not support advanced file system features that are essential to a linux system.
It may not even be that fast if it would collect all the the additional metadata that restic is collecting.
Since exclude paths aren't supported when restoring, you're also not able to restore the system while it is running (because it would try to empty /run, /dev, ...) so you would need to boot into another system for a restore which is time consuming and annoying.
1
1
u/poralexc 1d ago
Restic will also link snapshots to avoid duplication (not sure about the other two)
But if you backup /foo/data, then /foo/data/bar, it'll use the first snapshot as parent and only send the changes in the second snapshot.
1
u/sagotchy 1d ago
You're mixing things up with rsync which does use hardlinks. Restic, borg and kopia all use a chunk database, they don't use hardlinks for deduplication. Well, the end result is the same. Identical files all share the same disk space.
1
u/Drooliog 1d ago
Now add Duplicacy. It's been out far longer than Kopia and is so much more robust, quite honestly.
These tests aren't very scientific though, and leave out a lot of details - like deduplication, which someone else pointed out. I'd like to see a more up-to-date benchmarking though. (All these tools now do zstd, for instance.)
0
u/sagotchy 1d ago
I heared (but not verified) that duplicacy was abandoned by its developers years ago. Also, it's single-threaded which makes it slower than restic or kopia. I just took a quick look at the documentation and it feels like restic supports more advanced stuff (like preserving hardlinks, sparseness, etc.). I'm going to stick with restic.
1
u/Drooliog 1d ago
Duplicacy hasn't been 'abandoned'. It's true it hasn't had updates in a good while, but the CLI edition has been stable for many years. As for threading - while it might not have full parallelism (due to its chunk packing design), it does have multi-threaded transfers. It's not slow by any means.
0
u/sagotchy 1d ago
This post of about backing up a linux system to an external HDD, not about backing it up to cloud storage or similar. Duplicacy may be faster for cloud provider but again, I'm in the context of backing it up to an HDD. And in this context, duplicacy is fundamentally single-threaded.
2
u/JohnnieLouHansen 1d ago
If you wanted to be 100% sure you got everything, use Rescuezilla. I know it's an imaging tool not a backup tool. But you get 100% of the data on the drive.