borg [common options] init [options] [REPOSITORY]
positional arguments | ||
REPOSITORY |
repository to create | |
optional arguments | ||
-e MODE , --encryption MODE |
select encryption key mode (required) | |
--append-only |
create an append-only mode repository. Note that this only affects the low level structure of the repository, and running delete or prune will still be allowed. See Append-only mode (forbid compaction) in Additional Notes for more details. | |
--storage-quota QUOTA |
Set storage quota of the new repository (e.g. 5G, 1.5T). Default: no quota. | |
--make-parent-dirs |
create the parent directories of the repository directory, if they are missing. | |
--key-algorithm |
the algorithm we use to derive a key encryption key from your passphrase. Default: argon2 | |
This command initializes an empty repository. A repository is a filesystem directory containing the deduplicated data from zero or more archives.
The encryption mode can only be configured when creating a new repository - you can neither configure it on a per-archive basis nor change the mode of an existing repository. This example will likely NOT give optimum performance on your machine (performance tips will come below):
borg init --encryption repokey /path/to/repo
Borg will:
Make sure you use a good passphrase. Not too short, not too simple. The real encryption / decryption key is encrypted with / locked by your passphrase. If an attacker gets your key, he can’t unlock and use it without knowing the passphrase.
Be careful with special or non-ascii characters in your passphrase:
So better use a long passphrase made from simple ascii chars than one that includes non-ascii stuff or characters that are hard/impossible to enter on a different keyboard layout.
You can change your passphrase for existing repos at any time, it won’t affect the encryption/decryption key or other secrets.
Depending on your hardware, hashing and crypto performance may vary widely.
The easiest way to find out about what’s fastest is to run borg benchmark cpu
.
repokey modes: if you want ease-of-use and “passphrase” security is good enough -
the key will be stored in the repository (in repo_dir/config
).
keyfile modes: if you rather want “passphrase and having-the-key” security -
the key will be stored in your home directory (in ~/.config/borg/keys
).
The following table is roughly sorted in order of preference, the better ones are in the upper part of the table, in the lower part is the old and/or unsafe(r) stuff:
Mode (K = keyfile or repokey) | ID-Hash | Encryption | Authentication | V >= |
K-blake2-chacha20-poly1305 | BLAKE2b | CHACHA20 | POLY1305 | 1.3 |
K-chacha20-poly1305 | HMAC-SHA-256 | CHACHA20 | POLY1305 | 1.3 |
K-blake2-aes-ocb | BLAKE2b | AES256-OCB | AES256-OCB | 1.3 |
K-aes-ocb | HMAC-SHA-256 | AES256-OCB | AES256-OCB | 1.3 |
K-blake2 | BLAKE2b | AES256-CTR | BLAKE2b | 1.1 |
K | HMAC-SHA-256 | AES256-CTR | HMAC-SHA256 | any |
authenticated-blake2 | BLAKE2b | none | BLAKE2b | 1.1 |
authenticated | HMAC-SHA-256 | none | HMAC-SHA256 | 1.1 |
none | SHA-256 | none | none | any |
none mode uses no encryption and no authentication. You’re advised to NOT use this mode as it would expose you to all sorts of issues (DoS, confidentiality, tampering, …) in case of malicious activity in the repository.
If you do not want to encrypt the contents of your backups, but still want to detect malicious tampering use an authenticated mode. It’s like repokey minus encryption.
--key-algorithm argon2
is the default and is recommended.
The key encryption key is derived from your passphrase via argon2-id.
Argon2 is considered more modern and secure than pbkdf2.--key-algorithm pbkdf2
if you want to access your repo via old versions of borg.Our implementation of argon2-based key algorithm follows the cryptographic best practices:
--key-algorithm pbkdf2
uses the same key for both.--key-algorithm pbkdf2
Neither is inherently linked to the key derivation function, but since we were going to break backwards compatibility anyway we took the opportunity to fix all 3 issues at once.
# Local repository, recommended repokey AEAD crypto modes
$ borg init --encryption=repokey-aes-ocb /path/to/repo
$ borg init --encryption=repokey-chacha20-poly1305 /path/to/repo
$ borg init --encryption=repokey-blake2-aes-ocb /path/to/repo
$ borg init --encryption=repokey-blake2-chacha20-poly1305 /path/to/repo
# Local repository (no encryption), not recommended
$ borg init --encryption=none /path/to/repo
# Remote repository (accesses a remote borg via ssh)
# repokey: stores the (encrypted) key into <REPO_DIR>/config
$ borg init --encryption=repokey-aes-ocb user@hostname:backup
# Remote repository (accesses a remote borg via ssh)
# keyfile: stores the (encrypted) key into ~/.config/borg/keys/
$ borg init --encryption=keyfile-aes-ocb user@hostname:backup