···
1
-
<chapter xmlns="http://docbook.org/ns/docbook"
2
-
xmlns:xlink="http://www.w3.org/1999/xlink"
3
-
xmlns:xi="http://www.w3.org/2001/XInclude"
5
-
xml:id="module-borgbase">
6
-
<title>BorgBackup</title>
1
+
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="module-borgbase">
2
+
<title>BorgBackup</title>
8
-
<emphasis>Source:</emphasis>
9
-
<filename>modules/services/backup/borgbackup.nix</filename>
12
-
<emphasis>Upstream documentation:</emphasis>
13
-
<link xlink:href="https://borgbackup.readthedocs.io/"/>
16
-
<link xlink:href="https://www.borgbackup.org/">BorgBackup</link> (short: Borg)
17
-
is a deduplicating backup program. Optionally, it supports compression and
18
-
authenticated encryption.
4
+
<emphasis>Source:</emphasis>
5
+
<filename>modules/services/backup/borgbackup.nix</filename>
21
-
The main goal of Borg is to provide an efficient and secure way to backup
22
-
data. The data deduplication technique used makes Borg suitable for daily
23
-
backups since only changes are stored. The authenticated encryption technique
24
-
makes it suitable for backups to not fully trusted targets.
26
-
<section xml:id="module-services-backup-borgbackup-configuring">
27
-
<title>Configuring</title>
8
+
<emphasis>Upstream documentation:</emphasis>
9
+
<link xlink:href="https://borgbackup.readthedocs.io/" role="uri">https://borgbackup.readthedocs.io/</link>
29
-
A complete list of options for the Borgbase module may be found
30
-
<link linkend="opt-services.borgbackup.jobs">here</link>.
12
+
<link xlink:href="https://www.borgbackup.org/">BorgBackup</link>
13
+
(short: Borg) is a deduplicating backup program. Optionally, it
14
+
supports compression and authenticated encryption.
33
-
<section xml:id="opt-services-backup-borgbackup-local-directory">
34
-
<title>Basic usage for a local backup</title>
37
-
A very basic configuration for backing up to a locally accessible directory
17
+
The main goal of Borg is to provide an efficient and secure way to
18
+
backup data. The data deduplication technique used makes Borg
19
+
suitable for daily backups since only changes are stored. The
20
+
authenticated encryption technique makes it suitable for backups to
21
+
not fully trusted targets.
23
+
<section xml:id="module-services-backup-borgbackup-configuring">
24
+
<title>Configuring</title>
26
+
A complete list of options for the Borgbase module may be found
27
+
<link linkend="opt-services.borgbackup.jobs">here</link>.
30
+
<section xml:id="opt-services-backup-borgbackup-local-directory">
31
+
<title>Basic usage for a local backup</title>
33
+
A very basic configuration for backing up to a locally accessible
opt.services.borgbackup.jobs = {
44
-
exclude = [ "/nix" "/path/to/local/repo" ];
45
-
repo = "/path/to/local/repo";
40
+
paths = "/";
41
+
exclude = [ "/nix" "/path/to/local/repo" ];
42
+
repo = "/path/to/local/repo";
49
-
passphrase = "secret";
45
+
mode = "repokey";
46
+
passphrase = "secret";
51
-
compression = "auto,lzma";
48
+
compression = "auto,lzma";
49
+
startAt = "weekly";
57
+
If you do not want the passphrase to be stored in the
58
+
world-readable Nix store, use passCommand. You find an example
63
+
<section xml:id="opt-services-backup-create-server">
64
+
<title>Create a borg backup server</title>
61
-
If you do not want the passphrase to be stored in the world-readable
62
-
Nix store, use passCommand. You find an example below.
66
+
You should use a different SSH key for each repository you write
67
+
to, because the specified keys are restricted to running borg
68
+
serve and can only access this single repository. You need the
69
+
output of the generate pub file.
66
-
<section xml:id="opt-services-backup-create-server">
67
-
<title>Create a borg backup server</title>
68
-
<para>You should use a different SSH key for each repository you write to,
69
-
because the specified keys are restricted to running borg serve and can only
70
-
access this single repository. You need the output of the generate pub file.
74
-
<prompt># </prompt>sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_my_borg_repo
75
-
<prompt># </prompt>cat /run/keys/id_ed25519_my_borg_repo
72
+
# sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_my_borg_repo
73
+
# cat /run/keys/id_ed25519_my_borg_repo
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos
Add the following snippet to your NixOS configuration:
services.borgbackup.repos = {
86
-
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos"
84
+
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID78zmOyA+5uPG4Ot0hfAy+sLDPU1L4AiIoRYEIVbbQ/ root@nixos"
88
-
path = "/var/lib/my_borg_repo" ;
86
+
path = "/var/lib/my_borg_repo" ;
92
+
<section xml:id="opt-services-backup-borgbackup-remote-server">
93
+
<title>Backup to the borg repository server</title>
95
+
The following NixOS snippet creates an hourly backup to the
96
+
service (on the host nixos) as created in the section above. We
97
+
assume that you have stored a secret passphrasse in the file
98
+
<filename>/run/keys/borgbackup_passphrase</filename>, which should
99
+
be only accessible by root
96
-
<section xml:id="opt-services-backup-borgbackup-remote-server">
97
-
<title>Backup to the borg repository server</title>
98
-
<para>The following NixOS snippet creates an hourly backup to the service
99
-
(on the host nixos) as created in the section above. We assume
100
-
that you have stored a secret passphrasse in the file
101
-
<filename>/run/keys/borgbackup_passphrase</filename>, which should be only
services.borgbackup.jobs = {
109
-
paths = [ "/etc/nixos" ];
105
+
paths = [ "/etc/nixos" ];
111
-
repo = "borg@nixos:." ;
107
+
repo = "borg@nixos:." ;
113
-
mode = "repokey-blake2";
114
-
passCommand = "cat /run/keys/borgbackup_passphrase";
109
+
mode = "repokey-blake2";
110
+
passCommand = "cat /run/keys/borgbackup_passphrase";
116
-
environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_my_borg_repo"; };
117
-
compression = "auto,lzma";
118
-
startAt = "hourly";
112
+
environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_my_borg_repo"; };
113
+
compression = "auto,lzma";
114
+
startAt = "hourly";
124
-
<para>The following few commands (run as root) let you test your backup.
126
-
> nixos-rebuild switch
120
+
The following few commands (run as root) let you test your backup.
123
+
> nixos-rebuild switch
...restarting the following units: polkit.service
128
-
> systemctl restart borgbackup-job-backupToLocalServer
130
-
> systemctl restart borgbackup-job-backupToLocalServer
131
-
> export BORG_PASSPHRASE=topSecrect
132
-
> borg list --rsh='ssh -i /run/keys/id_ed25519_my_borg_repo' borg@nixos:.
125
+
> systemctl restart borgbackup-job-backupToLocalServer
127
+
> systemctl restart borgbackup-job-backupToLocalServer
128
+
> export BORG_PASSPHRASE=topSecrect
129
+
> borg list --rsh='ssh -i /run/keys/id_ed25519_my_borg_repo' borg@nixos:.
nixos-backupToLocalServer-2020-03-30T21:46:17 Mon, 2020-03-30 21:46:19 [84feb97710954931ca384182f5f3cb90665f35cef214760abd7350fb064786ac]
nixos-backupToLocalServer-2020-03-30T21:46:30 Mon, 2020-03-30 21:46:32 [e77321694ecd160ca2228611747c6ad1be177d6e0d894538898de7a2621b6e68]
134
+
<section xml:id="opt-services-backup-borgbackup-borgbase">
135
+
<title>Backup to a hosting service</title>
137
+
Several companies offer
138
+
<link xlink:href="https://www.borgbackup.org/support/commercial.html">(paid)
139
+
hosting services</link> for Borg repositories.
139
-
<section xml:id="opt-services-backup-borgbackup-borgbase">
140
-
<title>Backup to a hosting service</title>
143
-
Several companies offer <link
144
-
xlink:href="https://www.borgbackup.org/support/commercial.html">(paid)
145
-
hosting services</link> for Borg repositories.
148
-
To backup your home directory to borgbase you have to:
153
-
Generate a SSH key without a password, to access the remote server. E.g.
142
+
To backup your home directory to borgbase you have to:
147
+
Generate a SSH key without a password, to access the remote
sudo ssh-keygen -N '' -t ed25519 -f /run/keys/id_ed25519_borgbase
163
-
Create the repository on the server by following the instructions for your
169
-
Initialize the repository on the server. Eg.
156
+
Create the repository on the server by following the
157
+
instructions for your hosting server.
162
+
Initialize the repository on the server. Eg.
sudo borg init --encryption=repokey-blake2 \
172
-
-rsh "ssh -i /run/keys/id_ed25519_borgbase" \
166
+
-rsh "ssh -i /run/keys/id_ed25519_borgbase" \
zzz2aaaaa@zzz2aaaaa.repo.borgbase.com:repo
178
-
<para>Add it to your NixOS configuration, e.g.
172
+
Add it to your NixOS configuration, e.g.
services.borgbackup.jobs = {
184
-
exclude = [ "/nix" "'**/.cache'" ];
185
-
repo = "zzz2aaaaa@zzz2aaaaa.repo.borgbase.com:repo";
178
+
paths = [ "/" ];
179
+
exclude = [ "/nix" "'**/.cache'" ];
180
+
repo = "zzz2aaaaa@zzz2aaaaa.repo.borgbase.com:repo";
187
-
mode = "repokey-blake2";
188
-
passCommand = "cat /run/keys/borgbackup_passphrase";
182
+
mode = "repokey-blake2";
183
+
passCommand = "cat /run/keys/borgbackup_passphrase";
190
-
environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_borgbase"; };
191
-
compression = "auto,lzma";
185
+
environment = { BORG_RSH = "ssh -i /run/keys/id_ed25519_borgbase"; };
186
+
compression = "auto,lzma";
187
+
startAt = "daily";
<section xml:id="opt-services-backup-borgbackup-vorta">
202
-
<title>Vorta backup client for the desktop</title>
204
-
Vorta is a backup client for macOS and Linux desktops. It integrates the
205
-
mighty BorgBackup with your desktop environment to protect your data from
206
-
disk failure, ransomware and theft.
209
-
It can be installed in NixOS e.g. by adding <literal>pkgs.vorta</literal>
210
-
to <xref linkend="opt-environment.systemPackages" />.
213
-
Details about using Vorta can be found under <link
214
-
xlink:href="https://vorta.borgbase.com/usage">https://vorta.borgbase.com
196
+
<title>Vorta backup client for the desktop</title>
198
+
Vorta is a backup client for macOS and Linux desktops. It
199
+
integrates the mighty BorgBackup with your desktop environment to
200
+
protect your data from disk failure, ransomware and theft.
203
+
It can be installed in NixOS e.g. by adding
204
+
<literal>pkgs.vorta</literal> to
205
+
<xref linkend="opt-environment.systemPackages"></xref>.
208
+
Details about using Vorta can be found under
209
+
<link xlink:href="https://vorta.borgbase.com/usage">https://vorta.borgbase.com</link>