How I backup my Linux box

Preamble

I believe that knowing how to backup your Linux system is important, especially for a Linux newbie.   I also believe that not knowing how to backup is holding a lot of newbie's back from fulling enjoying Linux.   With the knowledge that you have a backup to fall back on, you can safely experiment and learn by tinkering with your system.

I'm not a teacher or expert with Linux, but I see the question of how to backup Linux repeatedly in the Linux news groups.  So I thought I'd create a page devoted to how I back my machine, partly as a personal cheat sheet for myself and partly to help out others.

My method is only one of many.  Other methods include "Mondo", "Mkcdrec", "dd" , "tar", "cp", "rsnc" and possibly more that I can't think of at the moment.   Each method has it's own pros and cons, and some will be more suitable to your situation than others.  For instance if you use removable hard drives of identicle size you could simply do similar to "dd if=/dev/hda of=/dev/hdb" from a rescue disk with "dd" on it.  NOTE: For now, I don't recommend backing up a system from within it self due to virtual file systems like /proc and /dev, (devfs) but as I'm a newbie I'm bound to be corrected on that point! and yes I have tried Mondo, it does seem to work, but I don't trust it and it's slow..


My Method

I use the CD version of R.I.P. which is a rescue disk with partimage on it.   From what I understand "partimage" is similar to "Norton Ghost", except that partimage doesn't burn images directly to CD.  No matter, as I burn the images later.
I use this method because because of it's speed and ease of use.   Although it's easy, it's not a push-a-button type of operation.
My Linux system consists of three partitions, one for /home, one swap and one for / which is everything else.

If you need more information on partimage it can be found here Partimage Org.

What's needed

  1. A resue CD with partimage on it.   One can be found here: http://www.tux.org/pub/people/kent-robotti/looplinux/rip
  2. To know the location of your Linux system eg: /dev/hda4
  3. To know the location of your backup space eg: /dev/hdb6 and enough free space on it to hold the backup.
  4. To know the location of your CD rom eg: /dev/hdc
/dev/hdb6 and /dev/hdc are examples only.   Change them in the following steps to suit your system.

Backing up

  1. Boot using the rescue CD. *
  2. At the prompt press enter
  3. Keyboard prompt enter for default keyboard
  4. Press enter for the command prompt.  You should now be logged in as root in the rescue system.
  5. Type mc and press enter.  You should now be running Midnight Commander.
  6. Navigate to /etc/fstab and press F4.  You should now be in editing mode in Midnight Commander.
    Add a new line reading  /dev/hda6  /mnt/win  vfat  defaults  0 0
    Note: I used vfat as the partition type because my backup partition is fat32, if yours it different change it accordingly eg: for ext2 you would naturally type in ext2 instead.  You can use /mnt/win in any case, it's just convenient as that mount point is already on the rescue system.
  7. Press enter to add blank line then press F2 to save.
  8. Type mount /mnt/win and press enter
  9. Type cd /mnt/win and press enter
  10. Type partimage and press enter.   You should now be running partimage with an easy Ncurses interface.  You should be able to use partimage without any instructions from me.   However one hint is to type in 655360 for split size so you get CD size images. **
  11. After the images have been created, reboot into your normal operating system and burn the images to CD using your favourite CD burning app.

Restoring

Restoring from the images on a hard drive is the simplest, but you can also restore from CD.
These are the steps to restore from CD:
  1. Boot using the rescue CD.
  2. At the prompt press enter.
  3. Keyboard prompt just press enter for the default keyboard.
  4. Press enter for the command prompt.  You should now be logged in as root in the rescue system.
  5. Type mc and press enter.  You should now be running Midnight Commander.
  6. Navigate to /etc/fstab and press F4.  You should now be in editing mode in Midnight Commander.
    Add a new line reading  /dev/hdc  /mnt/cdrom  iso9660  defaults  0 0
  7. Press enter to add blank line then press F2 to save.
  8. Type mount /mnt/cdrom and press enter.
  9. Type cd /mnt/cdrom and press enter.
  10. Now instead of typing partimage, you press CTRL-ALT-F2 to get to a new console.
  11. In the new console window type partimage.
  12. You should now be in partimage, just fill in the info and start your restore.
  13. If you have more than one CD image to restore partimage will prompt you saying it can't find the image of the next CD.   If so, the press CTRL-ALT-F1 to get to console 1 and umount /mnt/cdrom replace the cd with the next one then mount /mnt/cdrom , press CTRL-ALT-F2 and continue with partimage.   Repeat this until your restore is complete.
  14. When the restore is complete reboot.

*   If you can't boot the CD directly try using a boot disk eg: your Windows 98 startup disk
** KiloBytes, newer versions of the rescue CD with a newer partimage offer to split directly into MegaBytes

Revised: Jan. 23, 2004