Hard drive restoration from rsync backups

Contents: Conventions: Caveats: General Info:

Fedora Core hard drive restoration

How to get the information you'll need for the restore: Restoring a backup
  1. boot into rescue mode using the same version of Fedora Core as was installed (as the filesystems created by one may not be compatible with another), refuse any assistance (skip finding and mounting of filesystems, we don't care what's currently on the drive)
  2. for each disk:
    1. Run fdisk [disk-device].
    2. Create a new partition table by entering o
    3. Create new physical partitions (<= #4):
      1. enter n to begin
      2. enter p to create a physical partition
      3. enter partition number
      4. hit return to accept the precalculated start cylinder
      5. enter the size of the partition (+100M for 100 megabytes, for example)
      6. repeat for each physical parition
    4. If there are logical partitions (> #4):
      1. create an extended partition (should always be #4 if there are partitions >= 5)
        1. enter n to begin
        2. enter e to create the extended partition
        3. accept the defaults for start and end cylinder
      2. Create new logical partitions (>= #5) in numerical order
        1. enter n to begin
        2. accept the default start cylinder
        3. enter the size of the partition (+100M for 100 megabytes)
        4. repeat for each logical partition
    5. Change type of partitions
      1. if any partition (besides the extended partition) is not type 83 (Linux), such as swap partitions (which should be 82)
        1. enter t to change partition type
        2. if prompted, enter the number of the partition (if there is only one partition it will be assumed that it is being changed)
        3. enter the hex code for the new type of this partition
      2. Enter p to view the partition table
      3. Enter w to write the partition table to the disk
    6. Create file systems for each partition
      • For ext2 run mkfs.ext2 -L [volume-label] [partition]
      • For ext3 run mkfs.ext3 -L [volume-label] [partition]
      • For swap run mkswap -L [volume-label] [partition] (however note that not all versions of mkswap support labelling, leave out -L [volume-label] in these cases, or if there is no label to use)
    7. proceed to setup each drive
  3. Mount the filesystems
    1. Before a filesystem can be mounted all those logically containing it must be mounted, i.e. / must be mounted before /usr, which much be mounted before /usr/share (assuming that all of these are seperate filesystems)
    2. Create a directory to mount at, ex. mkdir [mountpoint], mkdir [mountpoint]/usr
    3. Set the user and group ownership of the new directory to root, and permissions to 0755, unless you know better (this is a reasonable default in case the filesystem fails to mount, when mounted the permissions of the root of the mounted filesystem will override this).
    4. Mount the filesystem into that directory, ex. mount -t ext3 [partition] [mountpoint] for / or mount -t ext2 [partition] [mountpoint]/usr for /usr, depending on the filesystem type
    5. proceed to mount all filesystems
  4. Mount the backup
    1. create a mount point, mkdir [backup-mountpoint]
    2. mount backup from hold:

      mount -t nfs hold:/backup/backups/[machine-name]

    3. The directory mounted contains each backup in its own directory. The directories are named in YYMMDD.hhmm format. Locate the most recent one. (either sort by name with ls or by last modification date with ls -tr)
  5. Restore the backup
    1. change into the directory to restore from, ex. cd [backup-mountpoint]/060606.0616/
    2. Run find . -depth -print | cpio -pdumv [mountpoint]. This will copy all of the files while maintaining modification dates, permissions, ownership, and directory structure.
  6. install boot block
    • with grub
      1. chroot [backup-mountpoint]
      2. run grub-install [boot-device], where [boot-device] is the device to install grub on (most likely the device for the drive (install to the MBR) if this is only a Linux machine)

Solaris 8 hard drive restoration

How to get the information you'll need for the restore: Restoring a backup
  1. Boot into Solaris 8 install, get a shell (Ctrl-C, return, 0, 0, return)
  2. Set up label (partition table) on each disk:
    1. run format
    2. enter the number of the disk to be setup from the list of available disks
    3. if disk is not formatted ([disk formatted] does not appear) enter format and follow the prompts
    4. enter modify to change the partition table
    5. choose to set the disk to "all free hog", which will start you with an empty partition table, answer yes when asked to confirm
    6. confirm
    7. choose a partition to set as free hog (you won't have to enter a size for this, it gets whatever is left over)
    8. enter a size for each partition as prompted
    9. confirm
    10. enter a name for the partition table (as far as I know this doesn't matter, I use "partition-table", with quotes)
    11. confirm (type yes)
    12. enter print to view table
    13. change partition tags and flags
      1. enter partition number
      2. enter a tag name
      3. enter flags (wu for swap, wm for msot everything else)
      4. accept the already entered values for partition start, end
    14. enter label to write to the disk
    15. enter quit to go up to the format menu
    16. enter verify to check the state of the partition table
    17. enter quit to leave format
  3. create filesystems
    • UFS
      1. run newfs [raw-partition]
    • swap - do nothing
    • anything else - ?
  4. mount filesystems
    Note: Before a filesystem can be mounted all those logically containing it must be mounted, i.e. / must be mounted before /usr, which much be mounted before /usr/share (assuming that all of these are seperate filesystems)
    1. make a mountpoint, ex. mkdir [mountpoint] for /, mkdir [mountpoint]/usr for /usr
    2. Set the user and group ownership of the new directory to root, and set permissions to 0755, unless you know better (this is a reasonable default in case the filesystem fails to mount, when mounted the permissions of the root of the mounted filesystem will override this).
    3. Mount the filesystem into that directory, ex. mount [partition] [mountpoint] or mount [partition] [mountpoint]/usr
  5. mount backup
    1. make a mountpoint for the backup
    2. mount -F hold:/backup/backups/[machine-name] [backup-mountpoint] (you may have to use hold's IP if DNS isn't working)
    3. The directory mounted contains each backup in its own directory. The directories are named in YYMMDD.hhmm format. Locate the most recent one (either sort by name with ls or by last modification date with ls -tr
  6. restore backup
    1. change into the directory containing the backup you want to restore, etc. cd [backup-mountpoint]/060606.0616/
    2. Run find . -print -depth | cpio -pdumv [mountpoint], where /mnt/root is where you mounted the root filesystem. This will copy all of the files while maintaining modification dates, permissions, ownership, and directory structure.

      You can exclude certain directories by piping the output of find through grep, ex. find . -print -depth | grep -v "^\./grad" | cpio -pdumv [mountpoint] to exclude /grad, pipe through additional greps for additional restrictions

  7. write boot block
    1. run installboot /usr/platform/[platform]/lib/fs/ufsbootblk [raw-partition], where [platform] is the platform that was used in the original system and [raw-partition] is the partition to which the root filesystem was installed.
  8. if the partitions you have created are not the same as the original configuration, edit the mounted etc/vfstab so the correct partitions will be mounted, most likely the first two columns will be all you need to change
  9. set up devices
    • If a tarball of the devices exists:
      1. retrieve it from whereever we decided to keep them
      2. extract them into the new filesystem with tar xvf [devices.tar] -C [mountpoint], where [devices.tar] is the tar with the devices.
    • otherwise you'll need to recreate them, as the backup is stored on a Linux machine which mangles the device numbers
      1. remove the dev and devices trees: rm -rf [mountpoint]/dev [mountpoint]/devices
      2. regenerate the devices: devfsadm -r [mountpoint]
      3. This may still not be right, especially if you are restoring a machine that was upgraded to Solaris 8 from an earlier version. Check that the major number of the devinfo device (ls -l [mountpoint]/devices/pseudo/devinfo@0:devinfo) is the same as the number the kernel you're installing expects (grep devinfo [mountpoint]/etc/name_to_major). If not:
        1. remove dev/msglog: rm [mountpoint]/dev/msglog (if that device is broken the system will not be able to perform its reconfiguration boot, removing it causes writes to it to create a regular file, which will soon after be replaced with the proper device)
        2. remove the devinfo devices: rm [mountpoint]/devices/pseudo/devinfo*
        3. create new devinfo device: mknod [mountpoint]/devices/pseudo/devinfo@0:devinfo c [devmajor] 0, where [devmajor] is the device major number you got from grep devinfo [mountpoint/etc/name_to_major].
  10. touch [mountpoint]/reconfigure to force Solaris to recheck its devices when it starts up.
  11. reboot
Login