XS Backup and Recovery with SysRescueCD: Difference between revisions
No edit summary |
No edit summary |
||
Line 17: | Line 17: | ||
Step 2. |
Step 2. |
||
Boot from the [[http://www.sysresccd.org/Main_Page SysRescueCD]] cd. If you plan to burn CD or DVD media, specify |
Boot from the [[http://www.sysresccd.org/Main_Page 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 |
'''boot:''' rescuecd docache |
||
If you are backing up to USB instead, you don't need the "docache" option, you can just press enter at "boot:" prompt. |
|||
Step 3. |
|||
Mount the /mnt/backup directory. 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. |
|||
<tt> |
|||
umount /library |
|||
mount /vol/VolGroup00/LogVol00 /mnt/backup |
|||
mkdir /mnt/backup/June18-2008 |
|||
</tt> |
|||
We will attach the external USB drive, and create a new subdirectory. |
|||
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. |
|||
<tt> |
|||
dmesg | grep usb |
|||
ls /dev/sd* |
|||
mount -t vfat /dev/sdf1 /mnt/backup |
|||
mkdir /mnt/backup/June18-2008 |
|||
</tt> |
|||
Step 4. |
|||
Now we are going to copy specific files to the /mnt/backup directory. These are files that |
|||
would be nice to be able to read from the backup media directly, without restore. All of |
|||
these are optional, and you can include others like your own README or special scripts. I find it is easiest to switch to the destination directory and copy files from various sources. |
|||
<tt> |
|||
⚫ | |||
⚫ | |||
[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 |
|||
</tt> |
|||
Step 5. |
|||
Backup the Master Boot Record and Disk Layout |
|||
<tt> |
<tt> |
||
[root /mnt/backup/June18-2008]# dd if=/dev/sda of=master.mbr bs=446 count=1 |
|||
⚫ | |||
[root /mnt/backup/June18-2008]# sfdisk -d > sfdisk-d.txt |
|||
⚫ | |||
[root /mnt/backup/June18-2008]# pvdisplay > pvdisplay.txt |
|||
[root ~]# cat boot-grub-menu.prep |
|||
[root /mnt/backup/June18-2008]# vgdisplay > vgdisplay.txt |
|||
# grub.conf generated by anaconda |
|||
[root /mnt/backup/June18-2008]# lvdisplay > lvdisplay.txt |
|||
# |
|||
# Note that you do not have to rerun grub after making changes to this file |
|||
# NOTICE: You have a /boot partition. This means that |
|||
# all kernel and initrd paths are relative to /boot/, eg. |
|||
# root (hd0,0) |
|||
# kernel /vmlinuz-version ro root=/dev/mapper/pdc_bbbhp2 |
|||
# initrd /initrd-version.img |
|||
#boot=/dev/mapper/pdc_bbbh |
|||
default=0 |
|||
timeout=30 |
|||
splashimage=(hd0,0)/grub/splash.xpm.gz |
|||
#hiddenmenu |
|||
title Fedora7 (2.6.23.17-88.fc7) |
|||
root (hd0,0) |
|||
kernel /vmlinuz-2.6.23.17-88.fc7 ro root=LABEL=FEDORA7 |
|||
initrd /initrd-2.6.23.17-88.fc7.img |
|||
</tt> |
</tt> |
||
Revision as of 18:25, 19 June 2008
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 )
Step 1. Capture all of the RPM packages installed. This can only be done from a running system.
[root ~]# cd /root [root ~]# rpm -qa | sort > rpm-qa.txt
Step 2. 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 USB instead, you don't need the "docache" option, you can just press enter at "boot:" prompt.
Step 3. Mount the /mnt/backup directory. 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.
umount /library mount /vol/VolGroup00/LogVol00 /mnt/backup mkdir /mnt/backup/June18-2008
We will attach the external USB drive, and create a new subdirectory. 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.
dmesg | grep usb ls /dev/sd* mount -t vfat /dev/sdf1 /mnt/backup mkdir /mnt/backup/June18-2008
Step 4. Now we are going to copy specific files to the /mnt/backup directory. These are files that would be nice to be able to read from the backup media directly, without restore. All of these are optional, and you can include others 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
Step 5. Backup the Master Boot Record and Disk Layout
[root /mnt/backup/June18-2008]# dd if=/dev/sda of=master.mbr bs=446 count=1 [root /mnt/backup/June18-2008]# sfdisk -d > sfdisk-d.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
Capture the file system table (fstab). These are the file systems mounted at boot time. Notice that I use LABEL=FEDORA7 for the root directory, LABEL=BOOT for the boot directory, and LABEL=SWAP1 for the swap space. Using LABEL= will make the process easier when we re-assemble all of the pieces into the final system.
[root ~]# cd /root [root ~]# cp /etc/fstab etc-fstab.prep [root ~]# cat etc-fstab.prep LABEL=FEDORA7 / ext3 defaults 1 1 LABEL=BOOT /boot ext3 defaults 1 2 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 LABEL=SWAP1 none swap defaults 0 0
Capture the disk layout. We will be making a new disk layout, but this information could be helpful during re-assembly.
[root ~]# cd /root [root ~]# sfdisk -d /dev/sda > sfdisk-d.prep [root ~]# cat sfdisk-d.prep # partition table of /dev/sda unit: sectors /dev/sda1 : start= 63, size= 1285137, Id=83, bootable /dev/sda2 : start= 1285200, size= 64581300, Id=83 /dev/sda3 : start= 0, size= 0, Id= 0 /dev/sda4 : start= 65866500, size= 4305420, Id= 5 /dev/sda5 : start= 65866563, size= 4305357, Id=82
Step 6. We will now backup this OS image. These backups will then be used to re-assemble the final system. For this example, I will use /dev/sdb3 (ext3) as temporary space to hold the backup images, and then burn onto DVD. If you have a large external USB drive, you could use that instead. To get a clean backup, I will boot from [[ http://sysresccd.org/Main_Page | SysRescCD 1.0.3 ]] and perform all my work from there. We see that /mnt/boot has only 19MB of data, and /mnt/base has 3.3GB of data. Both could fit on a single DVD. The "mount -l" shows that everything is mounted successfully.
[root ~]# cd /root [root ~]# mke2fs -L BACKUP -j /dev/sdb2 [root ~]# mkdir /mnt/boot /mnt/base /mnt/backup [root ~]# mount /dev/sda1 /mnt/boot [root ~]# mount /dev/sda2 /mnt/base [root ~]# mount /dev/sdb2 /mnt/backup [root ~]# du -sh /mnt/boot /mnt/base 19M /mnt/boot 3.3G /mnt/base [root ~]# mount -l tmpfs on / type tmpfs (rw) /dev/loop0 on /mnt/livecd type squashfs (ro,relatime) tmpfs on /mnt/cdrom type tmpfs (rw,relatime,size=204800k) ... /dev/sda1 on /mnt/boot type ext3 (rw) [BOOT] /dev/sda2 on /mnt/base type ext3 (rw) [FEDORA7] /dev/sdb3 on /mnt/backup type ext3 (rw) [BACKUP]
We will copy the information we captured in step 5 over to the backup directory.
[root ~]# cp /mnt/base/root/*.prep /mnt/backup
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. For BOOT, -z0 indicates no compression is required, as it is only a few MB in size. For the root partition, we use -z1 for gzip compression, and use "-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.
[root ~]# cd /mnt/backup [root /mnt/backup]# umount /mnt/boot [root /mnt/backup]# umount /mnt/base [root /mnt/backup]# sync [root /mnt/backup]# partimage -d -b -z0 save /dev/sda1 sda1-BOOT.img [root /mnt/backup]# partimage -d -b -z1 -V660 save /dev/sda1 sda1-BOOT.img Volume size: 692060160 bytes (660 MiB)
Thanks to compression, the 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]# ls boot-grub-menu.prep rpm-qa.prep sda2-FEDORA7.img.000 sfdisk-d.prep etc-fstab.prep sda1-BOOT.img.000 sda2-FEDORA7.img.001 [root /mnt/backup]# du -sh 1.1G . [root /mnt/backup]# 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]# cd /root [root /mnt/backup]# umount /mnt/backup [root /mnt/backup]# sync [root /mnt/backup]# eject