Backup Linux Operating System – PART-1
June 5, 2010
Ever wondered what would you do if the disk hosting your linux or Windows Operating System crashes? To avoid such unlikely events, backups are always recommended.I ran into a similar requirement for the media server I have at home. I was looking for a backup solution when I wanted to try my hands-on VMware ESXi .
I have CentOS 5 X86_64 installed on my server and after researching for quite sometime I came across a tool which could do my job effortlessly . The tool is called SystemRescueCD. Although this tool provides great amount of features, I will share the one’s which helped me backup and restore the system.
I’ve divided this tutorial in two parts, PART-1 is addressed to backup linux root partition and PART-2 will address on how to restore your OS in the event of a disk failure or for any reason you’d require to restore your OS. This is just one of many ways to take backup of an OS, you can find the whole list of softwares to suit your needs at http://en.wikipedia.org/wiki/List_of_backup_software.
Creation of SysRescueCD or USB
You can create a rescue cd from the ISO, The ISO can be downloaded from here . Alternatively you create a bootable USB stick using theISO(instructions below). I decided to go with the USB bootable stick. Heres the procedure I followed on Windows XP:
1. Mount the SysRescueCD ISO using Magic ISO/PowerISO/Daemon-tools or any emulation software of your choice.
2. Insert the USB and Find the drive letter, in my case its K:
3. Format the USB stick as FAT(NTFS wont work) , please see the screenshot.

4. Copy Files from SysRescueCD to USB stick(K:):
- Once the USB stick is formatted, copy the files from the SysRescueCD to the root of USB stick.
- Rename folder isolinux to syslinux in K:
- Go to K:syslinux folder, rename the file isolinux.cfg to syslinux.cfg
5. Make USB stick(K:) bootable
- Go to K:bootprog and unzip syslinux-3.85.zip(This would change for newer versions of sysrescuecd).
- Open command prompt and change location to K:bootprogwin32
- Run the following command to make the USB bootable:
syslinux -ma K:
-m means write mbr
-a means make drive partition active (aka bootable).
- Your USB stick is now bootable and ready to be used to take backups.
Booting SysRescueCD using USB
1. Ensure “Removable Devices” is set as the first priority in your bios settings.
2. Shutdown the Linux Host and boot with using the USB bootable stick we created earlier.
3. You will be presented with the following screen:
4. Choose the first option and press return key.
5. Once the boot process is complete, you will be presented with the following screen.
As you can see from the above, you are given many options to connect to this console. Now lets proceed with the backup.
Performing Backup
SysRescueCD gives you majorly two options to backup the file systems.
- fsarchiver
- partimage
In this tutorial I will use fsarchiver.
The following is the file system layout, In this scenario I will take a backup of the OS on /backup partition which is a separate hard disk dedicated to take backups.
[root@oralin05 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 7.7G 2.7G 4.6G 37% / /dev/sda1 99M 12M 82M 13% /boot tmpfs 506M 0 506M 0% /dev/shm /dev/sdb1 7.9G 147M 7.4G 2% /backup [root@oralin05 ~]#
As you can see /dev/sda holds the root & boot partition and /dev/sdb is used for backups. If you would like to take tape backups, it will be /dev/rmt[n]
1. Mount the directory you would like to take the backup:
root@sysresccd /root % mkdir /backup root@sysresccd /root % mount /dev/sdb1 /backup root@sysresccd /root % df -h | grep /backup /dev/sdb1 7.9G 147M 7.4G 2% /backup root@sysresccd /root %
2. Backup Master Boot Record(MBR)
root@sysresccd /root % dd if=/dev/sda of=/backup/sda-MBR-backup bs=512 count=1 1+0 records in 1+0 records out 512 bytes (512 B) copied, 0.00573138 s, 89.3 kB/s root@sysresccd /root %
3. Backup “/boot” and LVM hosting “/” root partition
The following command is used to take the backup:
#fsarchiver -v savefs /backup/backup-sda.fsa /dev/sda1 /dev/mapper/VolGroup00-LogVol00
Deciphering the above command:
-v is verbose
savefs is Save File System
/backup/backup-sda.fsa is the file which holds the backup followed by the partitions we need to backup.
The backup finishes with the following status:
Statistics for filesystem 1 * files successfully processed:....regfiles=104377, directories=11189, symlinks=12825, hardlinks=3975, specials=10 * files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0
4. Once backup is complete, you can verify the backup using the following command:
#fsarchiver archinfo /backup/backup-sda.fsa root@sysresccd /backup % fsarchiver archinfo /backup/backup-sda.fsa ====================== archive information ====================== Archive type: filesystems Filesystems count: 2 Archive id: 4be3d087 Archive file format: FsArCh_002 Archive created with: 0.6.8 Archive creation date: 2010-05-14_15-24-41 Archive label: <none> Minimum fsarchiver version: 0.6.4.0 Compression level: 3 (gzip level 6) Encryption algorithm: none ===================== filesystem information ==================== Filesystem id in archive: 0 Filesystem format: ext3 Filesystem label: /boot Filesystem uuid: 3124fbdf-4ae8-4557-9037-45501865b6c8 Original device: /dev/sda1 Original filesystem size: 98.72 MB (103512064 bytes) Space used in filesystem: 11.83 MB (12401664 bytes) ===================== filesystem information ==================== Filesystem id in archive: 1 Filesystem format: ext3 Filesystem label: Filesystem uuid: ede651ef-3d19-4d4d-9e65-a2e72672d492 Original device: /dev/mapper/VolGroup00-LogVol00 Original filesystem size: 7.63 GB (8190885888 bytes) Space used in filesystem: 2.65 GB (2847793152 bytes) root@sysresccd /backup %
5. Backup the partition table information, this is required to restore the non-root partitions if you have any on your server.
#sfdisk -d /dev/sda /backup/sda-part-table.sf
This is a text file, you can read the contents of this file.
That concludes the PART-1 of taking the backup of Linux Operating System using SysRescueCD.
I will post the PART-2 shortly …
fsarchiver archinfo /backup/backup-sda.fsa
Filed in Backup, Linux, Operating System, Uncategorized
Tags: Backup, Backup Linux, Backup Windows, Linux, Linux Backup, Operating System, Windows, Windows Backup


June 7, 2010 at 5:25 pm
Zakki, Good hands on guide for backing up linux system. Good reading ..
Thanks
Rupesh
June 7, 2010 at 5:28 pm
Thanks Rupesh!
June 18, 2010 at 12:50 pm
Great job ! Zakki bhai.