How to restore borg backups?
Borg is pretty good backup solution. I use it with BorgBase to backup my database for side projects and minecraft world. As Borg does deduplication your backups won't grow too much leading to huge invoices. The BorgBase is pretty good and I can recommend it.
Anyway I always forget how to restore borg backup. Here are command to do that:
List names of all backups:
borg list --format '{name}{NL}' ssh://xxxxxxxx@xxxxxxxx.repo.borgbase.com/./repo
If you want just the latest one add --last.
Find the one you want to restore. They have dates in the name. With BorgBase you
can also find out size change of the backup. borg
also can do this with
{size}
but you need to specify which archive you want it to list.
borg extract --list --progress "ssh://xxxxxxxx@xxxxxxxx.repo.borgbase.com/./repo::nixxy-borgbase-2025-02-21T00:00:05"
Downloads full backup. It will take time :)
Test it with --dry-run
.
When you backup your stuff you probably specified a full path to the files. For
example, I did a backup of /var/lib/minecraft/My World
. By default borg will
create ./var/lib/minecraft/My World
. To strip these first 3 directories use
--strip-components 3
.
To restore specific files or directories:
borg extract /path/to/repository::archive-name path/to/file path/to/directory
For extracting only certain file types or using patterns:
borg extract /path/to/repository::archive-name --pattern '*.jpg'
Use --exclude
to skip certain patterns.