Debian Codegraph @

doc/user-guide/12-BLOCKCLONE.adoc

raw
1 = BLOCKCLONE as backup method
2
3 BLOCKCLONE backup method is a bit distinct type of backup, which works directly
4 with block devices. It allows running backups of any kind of block device that
5 can be read/write by Linux drivers and save them to e.g. NFS share or USB
6 drive for later restore. It currently integrates Disk Dump (dd) and ntfsclone
7 (from ntfs-3g package). With BLOCKCLONE, user is also able to make full backup
8 and restore of dual boot (Linux / Windows) environments. +
9 Another potential use-case for the BLOCKCLONE method is to copy an encrypted
10 filesystem including the encryption layer by imaging the underlying block device.
11 This means that all existing encryption keys will be preserved and that the
12 resulting backup file (the image generated by `dd`) will itself remain encrypted.
13
14 == Limitations
15 - Works only directly with disk partitions (or Logical Volumes using `dd`)
16 - GPT not supported (work in progress)
17 - No UEFI support (work in progress)
18 - Linux family boot loader must be used as primary
19 (Windows bootloader was not tested)
20 - Restore should be done to same sized or larger disks
21 - Tests were made with Windows 7/10 with NFS and USB as destinations.
22 Other ReaR backup destinations like SMB or FTP might however work as well.
23
24 == Warning!
25 ReaR with BLOCKCLONE is capable of doing backup of Linux/Windows dual boot
26 environments. There is however a need for some basic knowledge on how the
27 source OS is set up. Things like boot loader device location, Linux/Windows
28 partitioning and file system layout are essential for backup setup. +
29 *Always test before relying on this approach!*
30
31 == Examples
32
33 === 1. Backup/restore of arbitrary block device with BLOCKCLONE and dd on NFS server
34
35 ==== Configuration
36 This is very basic and most simple scenario where we will do backup
37 of single partition (_/dev/sdc1_) located on separate disk (_/dev/sdc_). +
38 First we need to set some global options in _local.conf_,
39 like target for backups.
40 In our small example backups will be stored in _/mnt/rear_ directory
41 on BACKUP_URL NFS server.
42
43 ```
44 # cat local.conf
45 OUTPUT=ISO
46 BACKUP=NETFS
47 BACKUP_OPTIONS="nfsvers=3,nolock"
48 BACKUP_URL=nfs://<hostname>/mnt/rear
49 ```
50
51 Now we will define variables that will apply only for targeted block device
52
53 ```
54 # cat alien.conf
55 BACKUP=BLOCKCLONE # Define BLOCKCLONE as backup method
56 BACKUP_PROG_ARCHIVE="alien" # Name of image file
57 BACKUP_PROG_SUFFIX=".dd.img" # Suffix of image file
58 BACKUP_PROG_COMPRESS_SUFFIX="" # Don't use additional suffixes
59
60 BLOCKCLONE_PROG=dd # Use dd for image creation
61 BLOCKCLONE_PROG_OPTS="bs=4k" # Additional options that will be passed to dd
62 BLOCKCLONE_SOURCE_DEV="/dev/sdc1" # Device that should be backed up
63
64 BLOCKCLONE_SAVE_MBR_DEV="/dev/sdc" # Device where partitioning information is stored (optional)
65 BLOCKCLONE_MBR_FILE="alien_boot_strap.img" # Output filename for boot strap code
66 BLOCKCLONE_PARTITIONS_CONF_FILE="alien_partitions.conf" # Output filename for partition configuration
67
68 BLOCKCLONE_ALLOW_MOUNTED="yes" # Device can be mounted during backup (default NO)
69 ```
70
71 ==== Running backup
72 Save partitions configuration, bootstrap code and create actual backup of /dev/sdc1
73 ```
74 # rear -C alien mkbackuponly
75 ```
76
77 ==== Running restore from ReaR restore/recovery system
78 ```
79 # rear -C alien restoreonly
80 Restore alien.dd.img to device: [/dev/sdc1] # User is always prompted for restore destination
81 Device /dev/sdc1 was not found. # If destination does not exist ReaR will try to create it (or fail if BLOCKCLONE_SAVE_MBR_DEV was not set during backup)
82 Restore partition layout to (^c to abort): [/dev/sdc] # Prompt user for device where partition configuration should be restored
83 Checking that no-one is using this disk right now ... OK
84
85 Disk /dev/sdc: 5 GiB, 5368709120 bytes, 10485760 sectors
86 Units: sectors of 1 * 512 = 512 bytes
87 Sector size (logical/physical): 512 bytes / 512 bytes
88 I/O size (minimum/optimal): 512 bytes / 512 bytes
89
90 >>> Script header accepted.
91 >>> Script header accepted.
92 >>> Script header accepted.
93 >>> Script header accepted.
94 >>> Created a new DOS disklabel with disk identifier 0x10efb7a9.
95 Created a new partition 1 of type 'HPFS/NTFS/exFAT' and of size 120 MiB.
96 /dev/sdc2:
97 New situation:
98
99 Device Boot Start End Sectors Size Id Type
100 /dev/sdc1 4096 249855 245760 120M 7 HPFS/NTFS/exFAT
101
102 The partition table has been altered.
103 Calling ioctl() to re-read partition table.
104 Syncing disks.
105 ```
106
107 ==== Summary
108 In first example we have run backup of /dev/sdc1 partition and stored it on NFS
109 server. Saved image was later restored from ReaR rescue/recovery system.
110 ReaRs BLOCKCLONE will always ask user for restore destination, so it is users
111 responsibility to identify right target disk/partition prior restore.
112 Unlike NETFS backup method, no guesses about target devices will be made!
113
114 TIP: One of easiest ways how to identify right disk could be its size. +
115 Running `fdisk -l <device_file>` could be helpful.
116
117 During restore phase ReaR recognized that target partition does not exist and
118 asked if it should be created. If restore destination does not exist and
119 BLOCKCLONE_SAVE_MBR_DEV was set during backup, ReaR will try to deploy
120 partition setup from saved configuration files (BLOCKCLONE_MBR_FILE and
121 BLOCKCLONE_PARTITIONS_CONF_FILE) and continue with restore.
122
123 === 2. Backup/restore of Linux / Windows 10 dual boot setup with each OS on separate disk
124
125 ==== Configuration
126 In next example we will do backup/restore using BLOCKCLONE and `ntfsclone`
127 of Linux (installed on /dev/sda) and Windows 10 (installed on /dev/sdb).
128
129 TIP: You can locate right disk devices using `df` and `os-prober`
130 ```
131 # df -h /boot
132 Filesystem Size Used Avail Use% Mounted on
133 /dev/sda1 10G 4.9G 5.2G 49% / # Linux is most probably installed on /dev/sda
134
135 # os-prober
136 /dev/sdb1:Windows 10 (loader):Windows:chain # Windows 10 is most probably installed on /dev/sdb
137 ```
138
139 First we will configure some ReaR backup global options
140 (similar to link:12-BLOCKCLONE.adoc#1-backuprestore-of-arbitrary-block-device-with-blockclone-and-dd-on-nfs-server[first example]
141 we will do backup/restore with help of NFS server).
142
143 ```
144 # cat local.conf
145 OUTPUT=ISO
146 BACKUP=NETFS
147 BACKUP_OPTIONS="nfsvers=3,nolock"
148 BACKUP_URL=nfs://<hostname>/mnt/rear
149 REQUIRED_PROGS+=( ntfsclone )
150 ```
151
152 Now we will define backup parameters for Linux.
153
154 ```
155 # cat base_os.conf
156 this_file_name=$( basename ${BASH_SOURCE[0]} )
157 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
158 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
159 BACKUP_PROG_EXCLUDE+=( '/media/*' )
160 ```
161
162 Our Windows 10 is by default installed on two separate partitions
163 (partition 1 for boot data and partition 2 for disk C:),
164 so we will create two separate configuration files for each partition.
165
166 Windows boot partition:
167
168 ```
169 # cat windows_boot.conf
170 BACKUP=BLOCKCLONE
171 BACKUP_PROG_ARCHIVE="windows_boot"
172 BACKUP_PROG_SUFFIX=".img"
173 BACKUP_PROG_COMPRESS_SUFFIX=""
174
175 BLOCKCLONE_PROG=ntfsclone
176 BLOCKCLONE_SOURCE_DEV="/dev/sdb1"
177 BLOCKCLONE_PROG_OPTS="--quiet"
178
179 BLOCKCLONE_SAVE_MBR_DEV="/dev/sdb"
180 BLOCKCLONE_MBR_FILE="windows_boot_strap.img"
181 BLOCKCLONE_PARTITIONS_CONF_FILE="windows_partitions.conf"
182 ```
183
184 Windows data partition (disk C:\):
185 ```
186 # cat windows_data.conf
187 BACKUP=BLOCKCLONE
188 BACKUP_PROG_ARCHIVE="windows_data"
189 BACKUP_PROG_SUFFIX=".img"
190 BACKUP_PROG_COMPRESS_SUFFIX=""
191
192 BLOCKCLONE_PROG=ntfsclone
193 BLOCKCLONE_SOURCE_DEV="/dev/sdb2"
194 BLOCKCLONE_PROG_OPTS="--quiet"
195
196 BLOCKCLONE_SAVE_MBR_DEV="/dev/sdb"
197 BLOCKCLONE_MBR_FILE="windows_boot_strap.img"
198 BLOCKCLONE_PARTITIONS_CONF_FILE="windows_partitions.conf"
199 ```
200
201 ==== Running backup
202 First we will create backup of Linux. `mkbackup` command will create bootable
203 ISO image with ReaR rescue/recovery system that will be later used for
204 booting broken system and consecutive recovery.
205 ```
206 # rear -C base_os mkbackup
207 ```
208
209 Now we create backup of Windows 10 boot partition. Command `mkbackuponly`
210 will ensure that only partition data and partition layout will be saved
211 (ReaR rescue/recovery system will not be created which is exactly what we want).
212 ```
213 # rear -C windows_boot mkbackuponly
214 ```
215
216 Similarly, we create backup of Windows 10 data partition (disk C:\)
217 ```
218 # rear -C windows_data mkbackuponly
219 ```
220
221 ==== Running restore from ReaR restore/recovery system
222 As a first step after ReaR rescue/recovery system booted,
223 we will recover Linux. This step will recover all Linux file systems,
224 OS data and bootloader. Windows disk will remain untouched.
225 ```
226 # rear -C base_os recover
227 ```
228
229 In second step will recover Windows 10 boot partition. During this step ReaR
230 will detect that destination partition is not present and ask us for device
231 file where partition(s) should be created. It doesn't really matter whether
232 we decide to recover Windows 10 boot or data partition first.
233 `restoreonly` command ensures that previously restored Linux data and
234 partition(s) configuration (currently mounted under _/mnt/local_) will
235 remain untouched. Before starting Windows 10 recovery we should identify
236 right disk for recovery, as mentioned earlier disk size could be a good start.
237 ```
238 # fdisk -l /dev/sdb
239 Disk /dev/sdb: 50 GiB, 53687091200 bytes, 104857600 sectors
240 ```
241
242 _/dev/sdb_ looks to be right destination, so we can proceed with restore.
243 ```
244 # rear -C windows_boot restoreonly
245 Restore windows_boot.img to device: [/dev/sdb1]
246 Device /dev/sdb1 was not found.
247 Restore partition layout to (^c to abort): [/dev/sdb]
248 Checking that no-one is using this disk right now ... OK
249 ...
250 ```
251
252 Last step is to recover Windows 10 OS data (C:\).
253 Partitions on _/dev/sdb_ were already created in previous step,
254 hence ReaR will skip prompt for restoring partition layout.
255 ```
256 # rear -C windows_data restoreonly
257 Restore windows_data.img to device: [/dev/sdb2]
258 Ntfsclone image version: 10.1
259 Cluster size : 4096 bytes
260 Image volume size : 33833349120 bytes (33834 MB)
261 Image device size : 33833353216 bytes
262 Space in use : 9396 MB (27.8%)
263 Offset to image data : 56 (0x38) bytes
264 Restoring NTFS from image ...
265 ...
266 ```
267
268 At this stage Linux together with Windows 10 is successfully restored.
269
270 TIP: As Linux part is still mounted under _/mnt/local_, you can do some
271 final configuration changes. e.g. adapt GRUB configuration, /etc/fstab,
272 reinstall boot loader ...
273
274 TIP: ReaR will by default not include tools for mounting NTFS file systems. You
275 can do it manually by adding
276 `REQUIRED_PROGS+=( ntfsclone mount.ntfs-3g )`
277 to your _local.conf_
278
279 === 3. Backup/restore of Linux / Windows 10 dual boot setup sharing same disk
280
281 ==== Configuration
282 In this example we will do backup/restore using BLOCKCLONE and `ntfsclone`
283 of Linux and Windows 10 installed on same disk (_/dev/sda_).
284 Linux is installed on partition _/dev/sda3_. Windows 10 is again divided into
285 boot partition located on _/dev/sda1_ and OS data (C:/) located on _/dev/sda2_.
286 Backups will be stored on NFS server.
287
288 First we set global ReaR options
289 ```
290 # cat local.conf
291 OUTPUT=ISO
292 BACKUP=NETFS
293 BACKUP_OPTIONS="nfsvers=3,nolock"
294 BACKUP_URL=nfs://<hostname>/mnt/rear
295 REQUIRED_PROGS+=( ntfsclone )
296
297 BLOCKCLONE_STRICT_PARTITIONING="yes"
298 BLOCKCLONE_SAVE_MBR_DEV="/dev/sda"
299
300 BLOCKCLONE_MBR_FILE="boot_strap.img"
301 BLOCKCLONE_PARTITIONS_CONF_FILE="partitions.conf"
302
303 ```
304
305 IMPORTANT: BLOCKCLONE_STRICT_PARTITIONING is mandatory if backing up
306 Linux / Windows that shares one disk. Not using this option might result to
307 unbootable Windows 10 installation.
308
309 Linux configuration
310 ```
311 # cat base_os.conf
312 this_file_name=$( basename ${BASH_SOURCE[0]} )
313 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
314 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
315 BACKUP_PROG_EXCLUDE+=( '/media/*' )
316 ```
317
318 Windows 10 boot partition configuration
319 ```
320 # cat windows_boot.conf
321 BACKUP=BLOCKCLONE
322
323 BACKUP_PROG_ARCHIVE="windows_boot"
324 BACKUP_PROG_SUFFIX=".nc.img"
325 BACKUP_PROG_COMPRESS_SUFFIX=""
326
327 BLOCKCLONE_PROG=ntfsclone
328 BLOCKCLONE_PROG_OPTS="--quiet"
329
330 BLOCKCLONE_SOURCE_DEV="/dev/sda1"
331 ```
332
333 Windows 10 data partition configuration
334 ```
335 # cat windows_data.conf
336 BACKUP=BLOCKCLONE
337 BACKUP_PROG_ARCHIVE="windows_data"
338 BACKUP_PROG_SUFFIX=".nc.img"
339 BACKUP_PROG_COMPRESS_SUFFIX=""
340
341 BLOCKCLONE_PROG=ntfsclone
342 BLOCKCLONE_PROG_OPTS="--quiet"
343
344 BLOCKCLONE_SOURCE_DEV="/dev/sda2"
345 ```
346
347 ==== Running backup
348
349 Backup of Linux
350 ```
351 # rear -C base_os mkbackup
352 ```
353
354 Backup of Windows 10 boot partition
355 ```
356 # rear -C windows_boot mkbackuponly
357 ```
358
359 Backup of Windows 10 data partition
360 ```
361 # rear -C windows_data mkbackuponly
362 ```
363
364 ==== Running restore from ReaR restore/recovery system
365 Restore Linux
366 ```
367 # rear -C base_os recover
368 ```
369
370 During this step ReaR will also create both Windows 10 partitions
371
372 Restore Windows 10 data partition
373 ```
374 # rear -C windows_data restoreonly
375 ```
376
377 Restore Windows 10 boot partition
378 ```
379 # rear -C windows_boot restoreonly
380 ```
381
382 === 4. Backup/restore of Linux / Windows 10 dual boot setup sharing same disk with USB as destination
383
384 ==== Configuration
385 In this example we will do backup/restore using BLOCKCLONE and `ntfsclone`
386 of Linux and Windows 10 installed on same disk (_/dev/sda_).
387 Linux is installed on partition _/dev/sda3_. Windows 10 is again divided into
388 boot partition located on _/dev/sda1_ and OS data (C:/) located on _/dev/sda2_.
389 Backups will be stored on USB disk drive (_/dev/sdb_ in this example).
390
391 Global options
392 ```
393 # cat local.conf
394 OUTPUT=USB
395 BACKUP=NETFS
396
397 USB_DEVICE=/dev/disk/by-label/REAR-000
398 BACKUP_URL=usb:///dev/disk/by-label/REAR-000
399
400 USB_SUFFIX="USB_backups"
401
402 GRUB_RESCUE=n
403 REQUIRED_PROGS+=( ntfsclone )
404
405 BLOCKCLONE_STRICT_PARTITIONING="yes"
406 BLOCKCLONE_SAVE_MBR_DEV="/dev/sda"
407
408 BLOCKCLONE_MBR_FILE="boot_strap.img"
409 BLOCKCLONE_PARTITIONS_CONF_FILE="partitions.conf"
410 ```
411
412 Options used during Linux backup/restore.
413 ```
414 # cat local.conf
415 OUTPUT=USB
416 BACKUP=NETFS
417
418 USB_DEVICE=/dev/disk/by-label/REAR-000
419 BACKUP_URL=usb:///dev/disk/by-label/REAR-000
420
421 USB_SUFFIX="USB_backups"
422
423 GRUB_RESCUE=n
424 REQUIRED_PROGS+=( ntfsclone )
425
426 BLOCKCLONE_STRICT_PARTITIONING="yes"
427 BLOCKCLONE_SAVE_MBR_DEV="/dev/sda"
428
429 BLOCKCLONE_MBR_FILE="boot_strap.img"
430 BLOCKCLONE_PARTITIONS_CONF_FILE="partitions.conf"
431 ```
432
433 IMPORTANT: USB_SUFFIX option is mandatory as it avoids ReaR to hold every
434 backup in separate directory, this behavior is essential for BLOCKCLONE
435 backup method to work correctly.
436
437 Windows boot partition options
438 ```
439 # cat windows_boot.conf
440 BACKUP=BLOCKCLONE
441
442 BACKUP_PROG_ARCHIVE="windows_boot"
443 BACKUP_PROG_SUFFIX=".nc.img"
444 BACKUP_PROG_COMPRESS_SUFFIX=""
445
446 BLOCKCLONE_PROG=ntfsclone
447 BLOCKCLONE_PROG_OPTS="--quiet"
448
449 BLOCKCLONE_SOURCE_DEV="/dev/sda1"
450 ```
451
452 Windows data partition options
453 ```
454 # cat windows_data.conf
455 BACKUP=BLOCKCLONE
456 BACKUP_PROG_ARCHIVE="windows_data"
457 BACKUP_PROG_SUFFIX=".nc.img"
458 BACKUP_PROG_COMPRESS_SUFFIX=""
459
460 BLOCKCLONE_PROG=ntfsclone
461 BLOCKCLONE_PROG_OPTS="--quiet"
462
463 BLOCKCLONE_SOURCE_DEV="/dev/sda2"
464 ```
465
466 ==== Running backup
467 First we need to format target USB device, with `rear format` command
468 ```
469 # rear -v format /dev/sdb
470 Relax-and-Recover 2.00 / Git
471 Using log file: /var/log/rear/rear-centosd.log
472 USB device /dev/sdb is not formatted with ext2/3/4 or btrfs filesystem
473 Type exactly 'Yes' to format /dev/sdb with ext3 filesystem: Yes
474 Repartitioning '/dev/sdb'
475 Creating partition table of type 'msdos' on '/dev/sdb'
476 Creating ReaR data partition up to 100% of '/dev/sdb'
477 Setting 'boot' flag on /dev/sdb
478 Creating ext3 filesystem with label 'REAR-000' on '/dev/sdb1'
479 Adjusting filesystem parameters on '/dev/sdb1'
480 ```
481
482 Backup of Linux
483 ```
484 # rear -C base_os mkbackup
485 ```
486
487 Backup of Windows 10 boot partition
488 ```
489 # rear -C windows_boot mkbackuponly
490 NTFS volume version: 3.1
491 Cluster size : 4096 bytes
492 Current volume size: 524283904 bytes (525 MB)
493 Current device size: 524288000 bytes (525 MB)
494 Scanning volume ...
495 Accounting clusters ...
496 Space in use : 338 MB (64.4%)
497 Saving NTFS to image ...
498 Syncing ...
499 ```
500
501 Backup of Windows 10 data partition
502 ```
503 # rear -C windows_data mkbackuponly
504 NTFS volume version: 3.1
505 Cluster size : 4096 bytes
506 Current volume size: 18104709120 bytes (18105 MB)
507 Current device size: 18104713216 bytes (18105 MB)
508 Scanning volume ...
509 Accounting clusters ...
510 Space in use : 9833 MB (54.3%)
511 Saving NTFS to image ...
512 Syncing ...
513 ```
514
515 ==== Running restore from ReaR restore/recovery system
516 For sake of this demonstration I've purposely used ReaR's rescue/recovery media
517 (USB disk that holds our backed up Linux and Windows 10) as _/dev/sda_ and
518 disk that will be used as restore destination as _/dev/sdb_. This will
519 demonstrate possibility of ReaR to recover backup to arbitrary disk. +
520 As first step Linux will be restored, this will create all the partitions
521 needed, even those used by Windows 10.
522 ```
523 RESCUE centosd:~ # rear -C base_os recover
524 Relax-and-Recover 2.00 / Git
525 Using log file: /var/log/rear/rear-centosd.log
526 Sourcing additional configuration file '/etc/rear/base_os.conf'
527 Running workflow recover within the ReaR rescue/recovery system
528 Starting required daemons for NFS: RPC portmapper (portmap or rpcbind) and rpc.statd if available.
529 Started RPC portmapper 'rpcbind'.
530 RPC portmapper 'rpcbind' available.
531 Started rpc.statd.
532 RPC status rpc.statd available.
533 Using backup archive '/tmp/rear.70zIHqCYsIbtlr6/outputfs/centosd/backup-base_os.tar.gz'
534 Calculating backup archive size
535 Backup archive size is 1001M /tmp/rear.70zIHqCYsIbtlr6/outputfs/centosd/backup-base_os.tar.gz (compressed)
536 Comparing disks.
537 Device sda has size 15733161984, 37580963840 expected
538 Switching to manual disk layout configuration.
539 Original disk /dev/sda does not exist in the target system. Please choose an appropriate replacement.
540 1) /dev/sda
541 2) /dev/sdb
542 3) Do not map disk.
543 #?
544 ```
545
546 Now ReaR recover command stops as it detected that disk layout is not identical.
547 As our desired restore target is _/dev/sdb_ we choose right disk and continue
548 recovery. ReaR will ask to check created restore scripts, but this is not
549 needed in our scenario.
550 ```
551 #? 2
552 2017-01-25 20:54:01 Disk /dev/sdb chosen as replacement for /dev/sda.
553 Disk /dev/sdb chosen as replacement for /dev/sda.
554 This is the disk mapping table:
555 /dev/sda /dev/sdb
556 Please confirm that '/var/lib/rear/layout/disklayout.conf' is as you expect.
557
558 1) View disk layout (disklayout.conf) 4) Go to Relax-and-Recover shell
559 2) Edit disk layout (disklayout.conf) 5) Continue recovery
560 3) View original disk space usage 6) Abort Relax-and-Recover
561 #? 5
562 Partition primary on /dev/sdb: size reduced to fit on disk.
563 Please confirm that '/var/lib/rear/layout/diskrestore.sh' is as you expect.
564
565 1) View restore script (diskrestore.sh)
566 2) Edit restore script (diskrestore.sh)
567 3) View original disk space usage
568 4) Go to Relax-and-Recover shell
569 5) Continue recovery
570 6) Abort Relax-and-Recover
571 #? 5
572 Start system layout restoration.
573 Creating partitions for disk /dev/sdb (msdos)
574
575 Disk /dev/sdb: 6527 cylinders, 255 heads, 63 sectors/track
576 Old situation:
577 Units: cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
578
579 Device Boot Start End #cyls #blocks Id System
580 /dev/sdb1 * 0+ 91- 92- 731449 83 Linux
581 /dev/sdb2 91+ 3235- 3145- 25258396+ 83 Linux
582 /dev/sdb3 3235+ 6527- 3292- 26436900 83 Linux
583 /dev/sdb4 0 - 0 0 0 Empty
584 New situation:
585 Units: sectors of 512 bytes, counting from 0
586
587 Device Boot Start End #sectors Id System
588 /dev/sdb1 * 2048 1026047 1024000 7 HPFS/NTFS/exFAT
589 /dev/sdb2 1026048 36386815 35360768 7 HPFS/NTFS/exFAT
590 /dev/sdb3 36386816 73400319 37013504 83 Linux
591 /dev/sdb4 0 - 0 0 Empty
592 Successfully wrote the new partition table
593
594 Re-reading the partition table ...
595
596 Creating filesystem of type xfs with mount point / on /dev/sdb3.
597 Mounting filesystem /
598 Disk layout created.
599 Restoring from '/tmp/rear.70zIHqCYsIbtlr6/outputfs/centosd/backup-base_os.tar.gz'...
600 Restoring usr/lib/modules/3.10.0-514.2.2.el7.x86_64/kernel/drivers/net/wireless/realtek/rtlwifi/rtl8723be/rtl8723be.koRestoring var/log/rear/rear-centosd.log OK
601 Restored 2110 MiB in 103 seconds [avg. 20977 KiB/sec]
602 Restoring finished.
603 Restore the Mountpoints (with permissions) from /var/lib/rear/recovery/mountpoint_permissions
604 Patching '/etc/default/grub' instead of 'etc/sysconfig/grub'
605 Patching '/proc/1909/mounts' instead of 'etc/mtab'
606 Skip installing GRUB Legacy boot loader because GRUB 2 is installed (grub-probe or grub2-probe exist).
607 Installing GRUB2 boot loader
608 Finished recovering your system. You can explore it under '/mnt/local'.
609 Saving /var/log/rear/rear-centosd.log as /var/log/rear/rear-centosd-recover-base_os.log
610 ```
611
612 Now we have Linux part restored, GRUB installed and partitions created, hence
613 we can continue with Windows 10 boot partition recovery.
614 ```
615 RESCUE centosd:~ # rear -C windows_boot restoreonly
616 Restore windows_boot.nc.img to device: [/dev/sda1] /dev/sdb1
617 Ntfsclone image version: 10.1
618 Cluster size : 4096 bytes
619 Image volume size : 524283904 bytes (525 MB)
620 Image device size : 524288000 bytes
621 Space in use : 338 MB (64.4%)
622 Offset to image data : 56 (0x38) bytes
623 Restoring NTFS from image ...
624 Syncing ...
625 ```
626
627 Similarly to Linux restore, we were prompted for restore destination, which
628 is /dev/sdb1 in our case. +
629 As the last step we will recover Windows 10 data partition
630 ```
631 RESCUE centosd:~ # rear -C windows_data restoreonly
632 Restore windows_data.nc.img to device: [/dev/sda2] /dev/sdb2
633 Ntfsclone image version: 10.1
634 Cluster size : 4096 bytes
635 Image volume size : 18104709120 bytes (18105 MB)
636 Image device size : 18104713216 bytes
637 Space in use : 9867 MB (54.5%)
638 Offset to image data : 56 (0x38) bytes
639 Restoring NTFS from image ...
640 Syncing ...
641 ```
642
643 Again after restoreonly command is launched, ReaR prompts for restore
644 destination. +
645 Now both operating systems are restored and we can reboot.
646
647 === 5. Backup/restore of Linux to an NFS share with an encrypted device imaged using `dd`
648
649 ==== Configuration
650 In this example we will split the backup of a Linux-only machine into two parts. First,
651 we'll deal with the base OS the usual way (ignoring the encrypted filesystem), and
652 then we'll process that special filesystem (_/dev/vg00/lvol4_, mounted as
653 _/products_) using BLOCKCLONE and `dd`. +
654 As you will see, during the base OS restore phase, the encrypted filesystem will be
655 recreated with new encryption keys (although empty, as _/products_ was ignored during
656 the backup phase), but it will then be completely overwritten when we use `dd` to
657 restore the image in the last phase. +
658 The _BLOCKCLONE_TRY_UNMOUNT_ is important here: it will attempt to unmount the
659 encrypted filesystem before creating its image and before restoring it. If
660 unmounting is impossible, do not despair, the recovery should still work but
661 you may need to manually repair the filesystem before you can mount it, and you
662 run the risk that the data may be inconsistent.
663
664 Global options
665 ```
666 # cat site.conf
667 OUTPUT=ISO
668 KEEP_OLD_OUTPUT_COPY=1
669 BACKUP_URL="nfs://<hostname>/Stations_bkup/rear/"
670 ```
671
672 Options used for the base OS backup:
673 ```
674 # cat base_system.conf
675 this_file_name=$( basename ${BASH_SOURCE[0]} )
676 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
677 BACKUP_PROG_EXCLUDE+=( '/products/*' )
678 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
679 BACKUP=NETFS
680 ```
681
682 Options used to take the encrypted filesystem image:
683 ```
684 this_file_name=$( basename ${BASH_SOURCE[0]} )
685 LOGFILE="$LOG_DIR/rear-$HOSTNAME-$WORKFLOW-${this_file_name%.*}.log"
686 BACKUP=BLOCKCLONE
687 BACKUP_PROG_ARCHIVE="backup-${this_file_name%.*}"
688 BACKUP_PROG_SUFFIX=".dd.img"
689 BACKUP_PROG_COMPRESS_SUFFIX=""
690
691 BLOCKCLONE_PROG=dd
692 BLOCKCLONE_PROG_OPTS="bs=4k"
693 BLOCKCLONE_SOURCE_DEV="/dev/vg00/lvol4"
694
695 BLOCKCLONE_ALLOW_MOUNTED="yes"
696 BLOCKCLONE_TRY_UNMOUNT="yes"
697 ```
698
699 ==== Running backup
700 Base OS backup:
701 ```
702 # rear -C base_system mkbackup
703 ```
704
705 Create image of encrypted filesystem:
706 ```
707 # rear -C products_backup mkbackuponly
708 ```
709
710 ==== Running restore from ReaR restore/recovery system
711 First recover the base OS. This will create all the partitions needed, including
712 the encrypted one (but it won't restore any data for the latter). +
713 As illustrated below, you will be prompted to chose a new encryption passphrase.
714 Please provide one, but you need not care about its value as it will get overwritten
715 during the next phase:
716 ```
717 RESCUE pc-pan:~ # rear -C base_system.conf recover
718 [...]
719 Please enter the password for LUKS device cr_vg00-lvol4 (/dev/mapper/vg00-lvol4):
720 Enter passphrase for /dev/mapper/vg00-lvol4:
721 Please re-enter the password for LUKS device cr_vg00-lvol4 (/dev/mapper/vg00-lvol4):
722 Enter passphrase for /dev/mapper/vg00-lvol4:
723 Creating filesystem of type xfs with mount point /products on /dev/mapper/cr_vg00-lvol4.
724 Mounting filesystem /products
725 Disk layout created.
726 [...]
727 ```
728
729 Now we can proceed and restore the encrypted filesystem image. The target filesystem
730 will have been mounted by ReaR during the previous phase, but this will be
731 correctly handled by the restore script provided you set _BLOCKCLONE_TRY_UNMOUNT_
732 to "yes". +
733 As illustrated below, you will be prompted for the target block device to use.
734 Confirm by pressing Enter or type in another value:
735 ```
736 RESCUE pc-pan:~ # rear -C products_backup.conf restoreonly
737 [...]
738 Restore backup-products_backup.dd.img to device: [/dev/vg00/lvol4]
739 [...]
740 ```
741
742 Please note that the target device will not be re-mounted by the script at the end
743 of the restore phase. If needed, this should be done manually. +
744 The recovered machine can now be rebooted. When prompted for the passphrase to
745 decrypt your filesystem, you should now provide the original one (the one you used
746 at the time the backup was made), and NOT the new one you typed during the recover
747 phase.