Backup-and-Restore-Using-SysRescueCD

From OLPC
Revision as of 09:27, 21 June 2008 by Az990tony (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Here is a simple script to backup a one-drive XS School Server. It assumes the standard layout of a /boot, /(root) and Library directories. This assumes an external USB drive mounted at /mnt/backup.

We will boot from [[ http://sysresccd.org/Main_Page | SysRescCD 1.0.3 ]] and run the backup from there.

The partimage program is able to create backups of each partition, which can be any of the following:

  • primary partition (/dev/sda1, sda2, sda3)
  • logical partition (/dev/sda5, sda6, sda7)
  • RAID partitions (/dev/md1, md2, md3)
  • LVM2 Logical Volumes (/dev/VolGroup00/LogVol00, etc.)

#!/bin/sh
echo "* * * * * * * Backing up Master Boot Record"
dd if=/dev/sda of=master.mbr bs=446 count=1
echo " "
echo "* * * * * * * Backing up Disk Layout"
sfdisk -d /dev/sda > disk-sda.txt
sfdisk -d /dev/sdb > disk-sdb.txt
 echo "* * * * * * * Backing up /boot/grub/menu.lst "
mount /dev/md1 /mnt/custom
cp -L /mnt/custom/grub/menu.lst grubmenu.txt
echo "* * * * * * * Backing up /boot/details/* "
cp /mnt/custom/details/* .
umount /mnt/custom
echo "* * * * * * * Backing up /etc/fstab "
mount /dev/sda2 /mnt/custom
cp /mnt/custom/etc/fstab fstab.txt
umount /mnt/custom
echo "* * * Creating Partition Image: BOOT "
rm -f sda1*.img.*
partimage -d -b -z0 -V660 save /dev/sda1 sda1_boot.img
 echo "* * * Creating Partition Image: XS-163"
rm -f sda2*.img.*
partimage -d -b -z1 -V660 save /dev/sda2 sda2_xs163.img 
eject
ls
du -sh
echo "* * * Done"
exit 0