Home

Search this site:
 

Horshack’s
very
own site

 

This is Bavaria, Germany!
You will find links to Perl,
bootdisks for system administration,
a lot of Linux,
Windows administration
and some personal belongings.
Vserver: Backup/restore, do it fast

Vserver: Backup/restore, do it FAASSSSSST!

My goal

I want to restore a Linuxserver with Vservers installed as fast as possible.

Keep it simple? No, keep it simpler!

If you want to restore superfast think what can happen:

vserver_fastrestore_partitions.gifHow to react:

Think! This is about desaster recovery! This is about your nerves! Keep it simple, keep it standard!

On the picture you see how my system with vservers is built up.

Working for dooms day: backup your mothersystem

I backup to a large fileserver with Windows 2000 which itself gets backed up daily.

Create a disaster-backup of the mother-system:

  1. Backup of full mothersystem, track by track
    Create a backup _and_ restore it to another harddisk. It's worth nothing if you didn't test the recovery!
    1. Backup with Ghost:
      There seem to be problems with ghost when trying to make partition-images from Linux-partition. You have to prove wether it works for you.
    2. Backup with partimage. Get a rescue-CD from http://www.sysresccd.org, boot with it:
      # mkdir /mnt/sambaserver
      # smbmount //sambaserver/share /mnt/sambaserver -o username=yourname,password=yourpass,workgroup=yourworkgroup

      Backup your MBR first, because you love to forget this:
      # dd if=/dev/hda of=/mnt/sambaserver/mother_hda.mbr  bs=512 count=1

      Backup your whole first partition hda1, the partition of the mothership:
      # partimage --nodesc --compress=1 save /dev/hda1 /mnt/sambaserver/mother_hda1
    3. Don't backup ext3-data-partition /dev/hda3 because you will do daily/weekly tar- or rsync-backups.
      Partimage and Ghost seem to have a lot of problems with ext3, although it should simply work. But it doesn't. You will get problems only at recovery time which is more that bad!
    4. Don't backup swap-partition /dev/hda2
    5. Reboot your system and document your system with this shellscript
    6. #!/bin/sh
      # File: /root/bin/doku_server.sh
      set -x
      SERVER=tanzwut
      
      # Get partition sizes
      fdisk -l /dev/hda >${SERVER}_fdisk
      
      # Get ip-addresses
      ifconfig >${SERVER}_ifconfig
      
      # Get packages of mothership
      dpkg --get-selections \* >${SERVER}_pakete
      
      # Get hostname-lookup, nameserver
      cat /etc/resolv.conf >${SERVER}_resolv
      
      # Get mounted filesystems
      cat /etc/fstab >${SERVER}_fstab
      ls -l ${SERVER}*
      
    7. Save these files to a safe documentation place. Most important: fdisk with partition sizes.
  1. Again: restore your backup to another harddisk and test it.

Plan A: Daily backup to USB harddisks

vserver_fastrestore_backupdisks.gifThis is a pretty good idea! USB-harddisk are large and cheap. You can transport them to a safe place easily.

But USB, also USB-2, is slow. So you will not like to do full backups. But you must do backups as often as possible. Every other month is not enough!


Solution: backup to USB-harddisk with rsync. Take this script as an idea:

Backup to two harddisks, at least. Your rule should be:

There is always a new backup on one of the disk, you will never delete the newest backup.

Plan B: Daily backup to Samba-fileserver

Backup to a large fileserver via network with Windows 2000 which itself gets backed up daily.

  1. Install SMB on your mothersystem:
    apt-get install smbclient smbfs
  2. Mount an SMB-filesystem:
    mother# mount -t smbfs //sambaserver/share /mnt/sambaserver -o username=yourname,password=yourpass,workgroup=yourworkgroup
  3. Backup like in Plan A

Working for dooms day: the way to document

Let this run on the mothership. Put output-files to a safe place.

      #!/bin/sh
      # File: /root/bin/doku_server.sh
      set -x
      SERVER=tanzwut
      
      # Get partition sizes
      fdisk -l /dev/hda >${SERVER}_fdisk
      
      # Get ip-addresses
      ifconfig >${SERVER}_ifconfig
      
      # Get packages of mothership
      dpkg --get-selections \* >${SERVER}_pakete
      
      # Get hostname-lookup, nameserver
      cat /etc/resolv.conf >${SERVER}_resolv
      
      # Get mounted filesystems
      cat /etc/fstab >${SERVER}_fstab
      ls -l ${SERVER}*
      

Put an iso-image of your rescue-CD to that safe place: http://www.sysresccd.org or have at least one available.

Dooms day: how to recover totally

Have this ready:

  1. New system with new harddisk like the old one: ATA-disk as first master, so that /dev/hda on the old system is /dev/hda on the new one.
  2. Rescue-CD from http://www.sysresccd.org
  3. A printout of fstab of crashed system.

Do this:

  1. Boot with rescue-disk
  2. fdisk /dev/hda
    1. Delete all partitions on the harddisk
    2. Partition your harddisk:
      /dev/hda1 => 5 GBytes, Type 82, boot (type a for that)
      /dev/hda2 => 1 GByte,  Type 83 (type t for that)
      /dev/hda3 => Rest of harddisk, boot, Type 83
  3. Create filesystems
    1. Not for /dev/hda1, you will recover this in a minute from the image-file
    2. # mkswap /dev/hda2
    3. # mke2fs /dev/hda3
    4. # tune2fs -j /dev/hda3
  4. Mount your sambaserver with the root-device-image and the mbr-file
    # mkdir /mnt/sambaserver
    # mount -t smbfs \
    -o username=yourname,password=yourpass,workgroup=yourworkgroup  \
    //sambaserver/share /mnt/sambaserver
    # partimage restore /dev/hda1 /mnt/sambaserver
    # dd if=/mnt/sambaserver/mother_hda.mbr of=/dev/hda
  5. Reboot to get the mothership running
  6. Restore /data-partition with vservers with untar or whatever you have as software

 

Impressum