Zerocontent.org

Borg

Published: , Last modified:

Borg is a backup tool that is smart about deduplicating files and that can use ssh to store encrypted backups in a remote place. Borg must be installed on both the server and the client for this to work.

Backups are grouped in repositories. A repository contains all the backups for a bunch of files that you want to backup regularly. For instance, the contents of your home folder. In a repository one creates different archives, that is: different snapshots of the files at a certain time.

It is possible to share a single repository with different clients, but this is not efficient. Also, a client creates an exclusive lock, so simultaneous backups will fail. However, it can be useful to create the first snapshot through a different client if the backup is large and upload speed is limited.

Encryption

It is possible to store the encryption key outside the repository, use the keyfile mode when creating the repository. The key will be stored in ~/.config/borg/keys. Make sure to to export it and store it somewhere safe, so it will be possible to restore the backup on another device if the first one becomes inaccessible. One needs both the key and the passphrase to access the backup.

Commands

(The options -p and -s are for displaying progress and reposting stats respectively. They can be omitted for use in scripts.)

Create new repository: borg init --encryption=keyfile server:/path/to/repo

Create new archive in repository: borg create -p server:/path/to/repo::ARCHIVENAME ~/FOLDER1 ~/FOLDER2

List all archives: borg list server:/path/to/repo

Restore archive in the current directory: borg extract server:/path/to/repo::ARCHIVENAME

Delete old archives and recover diskspace: borg delete server:/path/to/repo::ARCHIVENAME

Export key: borg key export server:/path/to/repo exported.key

Import key: borg key import server:/path/to/repo exported.key

Source