Restore Partitions Using SystemRescueCD and FSArchiver
Partitions cannot be mounted when restoring to them. If services can be stopped that use files on a specific partition, it can be unmounted and restored. However, the root partition can never be restored while the server is online so these instructions will cover the common denominator which requires taking the server offline.
The server needs to be booted up with a CD but not just any CD will do because it needs to have FSArchiver on it. For this document, the ISO image from
www.sysresccd.org will be used.
Once downloaded, the ISO can be burned to a CD-ROM disc or uploaded to your ISO repository such as a LUN. VMware and VirtualBox can attach an ISO image and mount it in the CD-ROM device to allow the virtual machine to boot the ISO image.
For this example, files on the root and home partitions will be restored using this summarized procedure:
- Boot the system using the RescueCD.
- Mount the bak partition which contains the backup archives.
- Verify that the backup archives are in good condition.
- Restore the partitions.
- Mount the root and home partitions.
- Verify the restore worked.
- Unmount the partitions.
- Reboot the system.
Be sure the partitions have been backed up and the files are sitting in the /bak volume.
total 1199788
-rw------- 1 root root 119002341 May 31 14:22 srv-ubuntu-boot.fsa
-rw------- 1 root root 70 May 31 14:22 srv-ubuntu-boot.md5
-rw------- 1 root root 748 May 31 14:22 srv-ubuntu-boot.txt
-rw------- 1 root root 10639 May 31 14:23 srv-ubuntu-home.fsa
-rw------- 1 root root 70 May 31 14:23 srv-ubuntu-home.md5
-rw------- 1 root root 747 May 31 14:23 srv-ubuntu-home.txt
-rw------- 1 root root 5072 May 31 14:30 srv-ubuntu-opt.fsa
-rw------- 1 root root 69 May 31 14:30 srv-ubuntu-opt.md5
-rw------- 1 root root 745 May 31 14:30 srv-ubuntu-opt.txt
-rw------- 1 root root 1968035 May 31 14:23 srv-ubuntu-root.fsa
-rw------- 1 root root 70 May 31 14:23 srv-ubuntu-root.md5
-rw------- 1 root root 750 May 31 14:23 srv-ubuntu-root.txt
-rw------- 1 root root 5072 May 31 14:23 srv-ubuntu-srv.fsa
-rw------- 1 root root 69 May 31 14:23 srv-ubuntu-srv.md5
-rw------- 1 root root 745 May 31 14:23 srv-ubuntu-srv.txt
-rw------- 1 root root 8253 May 31 14:29 srv-ubuntu-tmp.fsa
-rw------- 1 root root 69 May 31 14:29 srv-ubuntu-tmp.md5
-rw------- 1 root root 744 May 31 14:29 srv-ubuntu-tmp.txt
-rw------- 1 root root 760951206 May 31 14:28 srv-ubuntu-usr.fsa
-rw------- 1 root root 69 May 31 14:28 srv-ubuntu-usr.md5
-rw------- 1 root root 748 May 31 14:28 srv-ubuntu-usr.txt
-rw------- 1 root root 346538394 May 31 14:29 srv-ubuntu-var.fsa
-rw------- 1 root root 69 May 31 14:29 srv-ubuntu-var.md5
-rw------- 1 root root 749 May 31 14:29 srv-ubuntu-var.txt
As a test of the restore, let's delete the two text files created in the previous section:
Code: Select all
rm /important.txt
rm /home/administrator/important.txt
These files should have been included in the backup image. When the restore is complete, these files should return.
Insert the SystemRescueCD CDROM (or mount the ISO image) and boot the server with it.
Here is the 1st screen:
Option #1 was chosen (SystemRescueCd: default boot options)
The next screen takes you to the command prompt:
Show what partitions the system has by using fsarchiver.
root@sysresccd /root %
fsarchiver probe simple
[======DISK======] [=============NAME==============] [====SIZE====] [MAJ] [MIN]
[sda ] [Virtual disk ] [ 30.00 GB] [ 8] [ 0]
[sr0 ] [VMware SATA CD00 ] [ 720.00 MB] [ 11] [ 0]
[=====DEVICE=====] [==FILESYS==] [======LABEL======] [====SIZE====] [MAJ] [MIN]
[loop0 ] [squashfs ] [<unknown> ] [ 647.75 MB] [ 7] [ 0]
[sda1 ] [<unknown> ] [<unknown> ] [ 1.00 MB] [ 8] [ 1]
[sda2 ] [ext4 ] [boot ] [ 1.00 GB] [ 8] [ 2]
[sda3 ] [LVM2_member] [<unknown> ] [ 28.00 GB] [ 8] [ 3]
[dm-0 ] [ext4 ] [root ] [ 6.00 GB] [254] [ 0]
[dm-1 ] [ext4 ] [home ] [ 1.00 GB] [254] [ 1]
[dm-2 ] [ext4 ] [srv ] [ 1.00 GB] [254] [ 2]
[dm-3 ] [ext4 ] [usr ] [ 5.00 GB] [254] [ 3]
[dm-4 ] [ext4 ] [var ] [ 3.00 GB] [254] [ 4]
[dm-5 ] [ext4 ] [tmp ] [ 3.00 GB] [254] [ 5]
[dm-6 ] [ext4 ] [opt ] [ 1.00 GB] [254] [ 6]
[dm-7 ] [ext4 ] [bak ] [ 4.00 GB] [254] [ 7]
Mount the bak partition which contains the backup archives.
root@sysresccd /root %
mkdir /bak
root@sysresccd /root %
mount --read-only /dev/dm-7 /bak
root@sysresccd /root %
ls -l /bak/partitions
total 1199788
-rw------- 1 root root 119002341 May 31 14:22 srv-ubuntu-boot.fsa
-rw------- 1 root root 70 May 31 14:22 srv-ubuntu-boot.md5
-rw------- 1 root root 748 May 31 14:22 srv-ubuntu-boot.txt
-rw------- 1 root root 10639 May 31 14:23 srv-ubuntu-home.fsa
-rw------- 1 root root 70 May 31 14:23 srv-ubuntu-home.md5
-rw------- 1 root root 747 May 31 14:23 srv-ubuntu-home.txt
-rw------- 1 root root 5072 May 31 14:30 srv-ubuntu-opt.fsa
-rw------- 1 root root 69 May 31 14:30 srv-ubuntu-opt.md5
-rw------- 1 root root 745 May 31 14:30 srv-ubuntu-opt.txt
-rw------- 1 root root 1968035 May 31 14:23 srv-ubuntu-root.fsa
-rw------- 1 root root 70 May 31 14:23 srv-ubuntu-root.md5
-rw------- 1 root root 750 May 31 14:23 srv-ubuntu-root.txt
-rw------- 1 root root 5072 May 31 14:23 srv-ubuntu-srv.fsa
-rw------- 1 root root 69 May 31 14:23 srv-ubuntu-srv.md5
-rw------- 1 root root 745 May 31 14:23 srv-ubuntu-srv.txt
-rw------- 1 root root 8253 May 31 14:29 srv-ubuntu-tmp.fsa
-rw------- 1 root root 69 May 31 14:29 srv-ubuntu-tmp.md5
-rw------- 1 root root 744 May 31 14:29 srv-ubuntu-tmp.txt
-rw------- 1 root root 760951206 May 31 14:28 srv-ubuntu-usr.fsa
-rw------- 1 root root 69 May 31 14:28 srv-ubuntu-usr.md5
-rw------- 1 root root 748 May 31 14:28 srv-ubuntu-usr.txt
-rw------- 1 root root 346538394 May 31 14:29 srv-ubuntu-var.fsa
-rw------- 1 root root 69 May 31 14:29 srv-ubuntu-var.md5
-rw------- 1 root root 749 May 31 14:29 srv-ubuntu-var.txt
Verify that the backup archives are in good condition:
root@sysresccd /root %
md5sum --check /bak/partitions/srv-ubuntu-root.md5
/bak/partitions/srv-ubuntu-root.fsa: OK
root@sysresccd /root %
md5sum --check /bak/partitions/srv-ubuntu-home.md5
/bak/partitions/srv-ubuntu-home.fsa: OK
Restore the root partition:
root@sysresccd /root %
fsarchiver restfs --cryptpass="abc123" /bak/partitions/srv-ubuntu-root.fsa id=0,dest=/dev/dm-0
Statistics for filesystem 0
* files successfully processed:....regfiles=941, directories=297, symlinks=620, hardlinks=0, specials=8
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0
Restore the home partition:
root@sysresccd /root %
fsarchiver restfs --cryptpass="abc123" /bak/partitions/srv-ubuntu-home.fsa id=0,dest=/dev/dm-1
Statistics for filesystem 0
* files successfully processed:....regfiles=11, directories=5, symlinks=0, hardlinks=0, specials=0
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0
Mount the root and home partitions:
root@sysresccd /root %
mkdir /mnt/root
root@sysresccd /root %
mkdir /mnt/home
root@sysresccd /root %
mount --read-only /dev/dm-0 /mnt/root
root@sysresccd /root %
mount --read-only /dev/dm-1 /mnt/home
Verify the restore worked:
root@sysresccd /root %
ls -l /mnt/root/import*
-rw-r--r-- 1 root root 0 May 3 17:00 important.txt
root@sysresccd /root %
ls -l /mnt/home/administrator/import*
-rw-r--r-- 1 root root 0 May 3 17:00 important.txt
Unmount the partitions:
root@sysresccd /root %
umount /mnt/root
root@sysresccd /root %
umount /mnt/home
root@sysresccd /root %
umount /bak
Eject the CDROM/ISO and reboot the server.
If it worked right, the server will boot up (we restored the root file system) and the test files should have been restored.
NOTE: If you noticed any ext file systems that had <unknown> labels, you can update them using the tune2fs command which makes identification easier when restoring.
Example 1:
Example 2: