XS Backup and Recovery with SysRescueCD

From OLPC
Jump to navigation Jump to search

This page will show how you can perform a full system backup (suitable for disaster recovery) of an XS School Server using [SysRescueCD]. This method can backup up to 700MB CD media, 4.7GB DVD media, or USB external storage.

( Alternative methods include XS_backup_restore Using rsync and XS_Backup_and_Disaster_Recovery Using Mondo Rescue )

Backing up your XS School Server

Step 1. Capture RPM package list

Capture all of the RPM packages installed. This should be done from a running XS schoolserver system. The rest of the steps will be done by booting from CD, but this is done from the running XS schoolserver itself.

[root ~]# cd /root
[root ~]# rpm -qa | sort > rpm-qa.txt

Step 2. Boot from SysRescueCD

Boot from the [SysRescueCD] cd. If you plan to burn CD or DVD media, specify the "docache" parameter which copies the entire contents of the CD into memory, so you need at least 1GB of RAM to use this option.

boot: rescuecd docache

If you are backing up to internal drive or external USB instead, you don't need the "docache" option, you can just press enter at "boot:" prompt.

Step 3. Make a directory to put your backups into

If you are burning to CD, we will temporarily use the /library directory on the XS hard disk, and then backup everything to CD. The "/mnt/backup" is already defined in the SysRescCD, so no need to "mkdir" for it. We will create a subdirectory with a date to remember when this was taken.

# Step 3--to CD or DVD
umount /library
mount /vol/VolGroup00/LogVol00 /mnt/backup
mkdir /mnt/backup/June18-2008

If we are backing up to an external USB disk instead, a few commands are different. You can boot up with the USB drive attached, or attach after the SysRescCD is up and running. Use these commands to help you figure out which device is appropriate for your USB device. I am using a 320GB drive in my examples, and found that it was attached at /dev/sdf1. My USB device is formatted FAT32 so that it can be used with Windows as well.

# Step 3--to External FAT32-formatted USB drive
dmesg | grep usb
ls /dev/sd*
mount -t vfat /dev/sdf1 /mnt/backup
mkdir /mnt/backup/June18-2008

Step 4. Backup the Master Boot Record and Disk Layout, and any LVM2 logical volume management configuration. The commands will run from whatever directory you are currently in, but I find it is easiest to switch to the destination directory so that there is less typing.

[root ~]# cd /mnt/backup/June18-2008
[root /mnt/backup/June18-2008]# dd if=/dev/sda of=xs163.mbr bs=446 count=1
[root /mnt/backup/June18-2008]# sfdisk -d > sfdisk-d.txt

Step 5. Now we are going to copy specific files that would be nice to be able to read from the backup media directly, without restore. All of these are optional, so you can skip this step if you are in a hurry. You can include other files like your own README or special scripts. I find it is easiest to switch to the destination directory and copy files from various sources.

[root ~]# cd /mnt/backup/June18-2008
[root /mnt/backup/June18-2008]# cp -L /boot/grub/menu.lst grubmenu.txt
[root /mnt/backup/June18-2008]# cp /root/rpm-qa.txt .
[root /mnt/backup/June18-2008]# cp /etc/fstab  etcfstab.txt
[root /mnt/backup/June18-2008]# fdisk -l > fdisk-l.txt
[root /mnt/backup/June18-2008]# pvdisplay > pvdisplay.txt
[root /mnt/backup/June18-2008]# vgdisplay > vgdisplay.txt
[root /mnt/backup/June18-2008]# lvdisplay > lvdisplay.txt

Step 6. We will now invoke partimage utility to perform the backups. partimage works with partitions that contain file systems, including logical volumes. Only the actual data is backed up, and compression options are available. The partitions must not be mounted during the partimage processing. Here are the compression options:

  • z0 -- means no compression, backups will be done very fast
  • z1 -- means gzip compression, this may take a few minutes, but will result in smaller outpu
  • z2 -- means bzip2 compression, takes much longer but creates the smallest output

I'll use z0 for /boot directory which is small, and z1 for the / (root) directory. I specify the "-V660" to indicate that the image should be split into pieces small enough to be burned onto a CDrom. (660 MiB is approximately 692 MB, and most CDrom can hold 700MB. Check your media for capacity. This is a good idea even if you are backing up to an external USB FAT32 drive, as FAT32 can only hold 2GB images maximum, so splitting them up into small pieces guarantees they won't encounter any FAT32 size limits.

[root /mnt/backup/June18-2008]# partimage -d -b -z0 save /dev/sda1 sda1-BOOT.img
[root /mnt/backup/June18-2008]# partimage -d -b -z1 -V660 save /dev/sda2 sda2-XS163.img
Volume size: 692060160 bytes (660 MiB)

Step 7. Thanks to compression, my entire backup directory is only 1.1GB in size. This could be burned onto two CDs or one DVD. In this case, we use growisofs to burn the list of files onto a single DVD.

[root /mnt/backup/June18-2008]# ls
grubmenu.txt  rpm-qa.prep       sda2-xs.img.000  sfdisk-d.txt
etcfstab.txt  sda1BOOT.img.000  sda2-xs.img.001  xs163.mbr
[root /mnt/backup/June18-2008]# du -sh
1.1G    .
[root /mnt/backup/June18-2008]# growisofs -Z /dev/dvd -R -J /mnt/backup/*
...
99.05% done, estimate finish Tue Jun 17 15:56:46 2008
Total translation table size: 0
Total rockridge attributes bytes: 874
Total directory bytes: 0
Path table size(bytes): 10
Max brk space used 0
535076 extents written (1045 MB)
builtin_dd: 535088*2KB out @ average 7.9x1352KBps
/dev/dvd: flushing cache
/dev/dvd: updating RMA
/dev/dvd: closing session
[root /mnt/backup/June18-2008]# cd /root
[root ~]#  umount /mnt/backup
[root ~]#  sync

Recovering your XS School Server