Debian Codegraph @

doc/user-guide/11-multiple-backups.adoc

raw
1
2 = Using Multiple Backups for Relax-and-Recover
3
4 == Basics
5
6 Currently multiple backups are only supported for:
7
8 * the internal BACKUP=NETFS method with BACKUP_TYPE=""
9 * the internal BACKUP=BLOCKCLONE method
10 * the external BACKUP=BORG method
11
12 In general multiple backups are not supported for
13 BACKUP_TYPE=incremental or BACKUP_TYPE=differential
14 because those require special backup archive file names.
15
16 === The basic idea behind
17
18 A "rear mkbackup" run can be split into
19 a "rear mkrescue" run plus a "rear mkbackuponly" run
20 and the result is still the same.
21
22 Accordingly "rear mkbackup" can be split into
23 a single "rear mkrescue" plus multiple "rear mkbackuponly"
24 where each particular "rear mkbackuponly" backups only a
25 particular part of the files of the system, for example:
26
27 * a backup of the files of the basic system
28 * a backup of the files in the /home directories
29 * a backup of the files in the /opt directory
30
31 Multiple "rear mkbackuponly" require that each particular
32 "rear mkbackuponly" uses a specific ReaR configuration file
33 that specifies how that particular "rear mkbackuponly" must be done.
34
35 Therefore the '-C' command line parameter is needed where
36 an additional ReaR configuration file can be specified.
37
38 === The basic way how to create multiple backups
39
40 Have common settings in /etc/rear/local.conf
41
42 For each particular backup specify its parameters in
43 separated additional configuration files like
44
45 ----
46 /etc/rear/basic_system.conf
47 /etc/rear/home_backup.conf
48 /etc/rear/opt_backup.conf
49 ----
50
51 First create the ReaR recovery/rescue system ISO image
52 together with a backup of the files of the basic system:
53
54 ----
55 rear -C basic_system mkbackup
56 ----
57
58 Then backup the files in the /home directories:
59
60 ----
61 rear -C home_backup mkbackuponly
62 ----
63
64 Afterwards backup the files in the /opt directory:
65
66 ----
67 rear -C opt_backup mkbackuponly
68 ----
69
70 === The basic way how to recover with multiple backups
71
72 The basic idea how to recover with multiple backups is
73 to split the "rear recover" into an initial recovery
74 of the basic system followed by several backup restore
75 operations as follows:
76
77 Boot the ReaR recovery/rescue system.
78
79 In the ReaR recovery/rescue system do the following:
80
81 First recover the basic system:
82
83 ----
84 rear -C basic_system recover
85 ----
86
87 Then restore the files in the /home directories:
88
89 ----
90 rear -C home_backup restoreonly
91 ----
92
93 Afterwards restore the files in the /opt directory:
94
95 ----
96 rear -C opt_backup restoreonly
97 ----
98
99 Finally reboot the recreated system.
100
101 For more internal details and some background information see
102 https://github.com/rear/rear/issues/1088
103
104 == Relax-and-Recover Setup for Multiple Backups
105
106 Assume for example multiple backups should be done
107 using the NETFS backup method with 'tar' as backup program
108 to get separated backups for:
109
110 * the files of the basic system
111 * the files in the /home directories
112 * the files in the /opt directory
113
114 Those four configuration files could be used:
115
116 ./etc/rear/local.conf
117 [source,bash]
118 ----
119 OUTPUT=ISO
120 BACKUP=NETFS
121 BACKUP_OPTIONS="nfsvers=3,nolock"
122 BACKUP_URL=nfs://your.NFS.server.IP/path/to/your/rear/backup
123 ----
124
125 ./etc/rear/basic_system.conf
126 [source,bash]
127 ----
128 this_file_name=$( basename ${BASH_SOURCE[0]} )
129 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
130 BACKUP_PROG_EXCLUDE+=( '/home/*' '/opt/*' )
131 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
132 ----
133
134 ./etc/rear/home_backup.conf
135 [source,bash]
136 ----
137 this_file_name=$( basename ${BASH_SOURCE[0]} )
138 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
139 BACKUP_ONLY_INCLUDE="yes"
140 BACKUP_PROG_INCLUDE=( '/home/*' )
141 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
142 ----
143
144 ./etc/rear/opt_backup.conf
145 [source,bash]
146 ----
147 this_file_name=$( basename ${BASH_SOURCE[0]} )
148 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
149 BACKUP_ONLY_INCLUDE="yes"
150 BACKUP_PROG_INCLUDE=( '/opt/*' )
151 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
152 ----
153
154 The BACKUP_ONLY_INCLUDE setting is described in conf/default.conf.
155
156 With those config files creating the ReaR recovery/rescue system ISO image
157 and subsequently backup the files of the system could be done like:
158
159 ----
160 rear mkrescue
161 rear -C basic_system mkbackuponly
162 rear -C home_backup mkbackuponly
163 rear -C opt_backup mkbackuponly
164 ----
165
166 Recovery of that system could be done by calling in the
167 ReaR recovery/rescue system:
168
169 ----
170 rear -C basic_system recover
171 rear -C home_backup restoreonly
172 rear -C opt_backup restoreonly
173 ----
174
175 Note that system recovery with multiple backups requires that
176 first and foremost the basic system is recovered where all files
177 must be restored that are needed to install the bootloader and
178 to boot the basic system into a normal usable state.
179
180 Nowadays systemd usually needs files in the /usr directory
181 so that in practice in particular all files in the /usr directory
182 must be restored during the initial basic system recovery
183 plus whatever else is needed to boot and run the basic system.
184
185 Multiple backups cannot be used to split the files of the basic system
186 into several backups. The files of the basic system must be in one
187 single backup and that backup must be restored during the initial
188 recovery of the basic system.
189
190 == Relax-and-Recover Setup for Different Backup Methods
191
192 Because multiple backups are used via separated additional
193 configuration files, different backup methods can be used.
194
195 Assume for example multiple backups should be used to get
196 separated backups for the files of the basic system
197 using the NETFS backup method with 'tar' as backup program
198 and to backup the files in the /home directory
199 using the BORG backup method.
200
201 The configuration files could be like the following:
202
203 ./etc/rear/local.conf
204 [source,bash]
205 ----
206 OUTPUT=ISO
207 REQUIRED_PROGS+=( borg locale )
208 COPY_AS_IS+=( "/borg/keys" )
209 ----
210
211 ./etc/rear/basic_system.conf
212 [source,bash]
213 ----
214 this_file_name=$( basename ${BASH_SOURCE[0]} )
215 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
216 BACKUP_PROG_EXCLUDE+=( '/home/*' )
217 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
218 BACKUP=NETFS
219 BACKUP_OPTIONS="nfsvers=3,nolock"
220 BACKUP_URL=nfs://your.NFS.server.IP/path/to/your/rear/backup
221 ----
222
223 ./etc/rear/home_backup.conf
224 [source,bash]
225 ----
226 this_file_name=$( basename ${BASH_SOURCE[0]} )
227 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
228 BACKUP=BORG
229 BACKUP_ONLY_INCLUDE="yes"
230 BACKUP_PROG_INCLUDE=( '/home/*' )
231 BORGBACKUP_ARCHIVE_PREFIX="rear"
232 BORGBACKUP_HOST="borg.server.name"
233 BORGBACKUP_USERNAME="borg_server_username"
234 BORGBACKUP_REPO="/path/to/borg/repository/on/borg/server"
235 BORGBACKUP_PRUNE_KEEP_HOURLY=5
236 BORGBACKUP_PRUNE_KEEP_WEEKLY=2
237 BORGBACKUP_COMPRESSION="zlib,9"
238 BORGBACKUP_ENC_TYPE="keyfile"
239 export BORG_KEYS_DIR="/borg/keys"
240 export BORG_CACHE_DIR="/borg/cache"
241 export BORG_PASSPHRASE='a1b2c3_d4e5f6'
242 export BORG_RELOCATED_REPO_ACCESS_IS_OK="yes"
243 export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK="yes"
244 export BORG_REMOTE_PATH="/usr/local/bin/borg"
245 ----
246
247 Using different backup methods requires to get all the binaries
248 and all other needed files of all used backup methods into the
249 ReaR recovery/rescue system during "rear mkbackup/mkrescue".
250
251 Those binaries and other needed files must be manually specified
252 via REQUIRED_PROGS and COPY_AS_IS in /etc/rear/local.conf
253 (regarding REQUIRED_PROGS and COPY_AS_IS see conf/default.conf).
254
255 With those config files creating the ReaR recovery/rescue system ISO image
256 together with a 'tar' backup of the files of the basic system and
257 a separated Borg backup of the files in /home could be done like:
258
259 ----
260 rear -C home_backup mkbackuponly
261 rear -C basic_system mkbackup
262 ----
263
264 In contrast to the other examples above the Borg backup is run first
265 because Borg creates encryption keys during repository initialization.
266 This ensures the right /borg/keys is created before it will be copied into
267 the ReaR recovery/rescue system by the subsequent "rear mkbackup/mkrescue".
268 Alternatively the ReaR recovery/rescue system could be created again
269 after the Borg backup is done like:
270
271 ----
272 rear -C basic_system mkbackup
273 rear -C home_backup mkbackuponly
274 rear -C basic_system mkrescue
275 ----
276
277 Recovery of that system could be done by calling in the
278 ReaR recovery/rescue system:
279
280 ----
281 rear -C basic_system recover
282 rear -C home_backup restoreonly
283 ----
284
285 == Running Multiple Backups and Restores in Parallel
286
287 When the files in multiple backups are separated from each other
288 it should work to run multiple backups or multiple restores in parallel.
289
290 Whether or not that actually works in your particular case
291 depends on how you made the backups in your particular case.
292
293 For sufficiently well separated backups it should work
294 to run multiple different
295
296 ----
297 rear -C backup_config mkbackuponly
298 ----
299
300 or multiple different
301
302 ----
303 rear -C backup_config restoreonly
304 ----
305
306 in parallel.
307
308 Running in parallel is only supported for mkbackuponly and restoreonly.
309
310 For example like
311
312 ----
313 rear -C backup1 mkbackuponly & rear -C backup2 mkbackuponly & wait
314 ----
315
316 or
317
318 ----
319 rear -C backup1 restoreonly & rear -C backup2 restoreonly & wait
320 ----
321
322 ReaR's default logging is not prepared for multiple simultaneous runs
323 and also ReaR's current progress subsystem is not prepared for that.
324 On the terminal the messages from different simultaneous runs are
325 indistinguishable and the current progress subsystem additionally
326 outputs subsequent messages on one same line which results
327 illegible and meaningless output on the terminal.
328
329 Therefore additional parameters must be set to make ReaR's messages
330 and the progress subsystem output appropriate for parallel runs.
331
332 Simultaneously running ReaR workflows require unique messages and
333 unique logfile names.
334
335 Therefore the PID ('$$') is specified to be used as message prefix
336 for all ReaR messages and it is also added to the LOGFILE value.
337
338 The parameters MESSAGE_PREFIX PROGRESS_MODE and PROGRESS_WAIT_SECONDS
339 are described in conf/default.conf.
340
341 For example a setup for parallel runs of mkbackuponly and restoreonly
342 could look like the following:
343
344 ./etc/rear/local.conf
345 [source,bash]
346 ----
347 OUTPUT=ISO
348 BACKUP=NETFS
349 BACKUP_OPTIONS="nfsvers=3,nolock"
350 BACKUP_URL=nfs://your.NFS.server.IP/path/to/your/rear/backup
351 MESSAGE_PREFIX="$$: "
352 PROGRESS_MODE="plain"
353 PROGRESS_WAIT_SECONDS="3"
354 ----
355
356 ./etc/rear/basic_system.conf
357 [source,bash]
358 ----
359 this_file_name=$( basename ${BASH_SOURCE[0]} )
360 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}-$$.log"
361 BACKUP_PROG_EXCLUDE+=( '/home/*' '/opt/*' )
362 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
363 ----
364
365 ./etc/rear/home_backup.conf
366 ----
367 this_file_name=$( basename ${BASH_SOURCE[0]} )
368 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}-$$.log"
369 BACKUP_ONLY_INCLUDE="yes"
370 BACKUP_PROG_INCLUDE=( '/home/*' )
371 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
372 ----
373
374 ./etc/rear/opt_backup.conf
375 [source,bash]
376 ----
377 this_file_name=$( basename ${BASH_SOURCE[0]} )
378 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}-$$.log"
379 BACKUP_ONLY_INCLUDE="yes"
380 BACKUP_PROG_INCLUDE=( '/opt/*' )
381 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
382 ----
383
384 With those config files creating the ReaR recovery/rescue system ISO image
385 together with a backup of the files of the basic system and then
386 backup the files in /home and /opt in parallel could be done like:
387
388 ----
389 rear -C basic_system mkbackup
390 rear -C home_backup mkbackuponly & rear -C opt_backup mkbackuponly & wait
391 ----
392
393 Recovery of that system could be done by calling in the
394 ReaR recovery/rescue system:
395
396 ----
397 rear -C basic_system recover
398 rear -C home_backup restoreonly & rear -C opt_backup restoreonly & wait
399 ----
400
401 Even on a relatively small system with a single CPU
402 running multiple backups and restores in parallel
403 can be somewhat faster compared to sequential processing.
404
405 On powerful systems with multiple CPUs, much main memory, fast storage access,
406 and fast access to the backups it is in practice mandatory to split
407 a single huge backup of the whole system into separated parts and
408 run at least the restores in parallel to utilize powerful hardware
409 and be as fast as possible in case of emergency and time pressure
410 during a real disaster recovery.
411
412 Remember that system recovery with multiple backups requires that
413 first and foremost the basic system is recovered where all files
414 must be restored that are needed to install the bootloader and
415 to boot the basic system into a normal usable state so that
416 'rear recover' cannot run in parallel with 'rear restoreonly'.
417