Linux

Configure IT Quick: Use Mondo Rescue to back up Linux servers

This tutorial shows how to use the open source Mondo Rescue software to backup data on a Linux system.

Mondo Rescue is a full-featured open source backup program for use on Linux systems. It is a comprehensive software package that allows you to back up to CD-R, CD-RW, NFS, tape, or ISO image. It also allows you to make a complete clone of a server-based system state. This means you can quickly restore to a working image from a complete data loss or just verify current files based on a known good backup. Mondo is available free under the GPL (GNU Public License) and has been tested on a number of Linux distributions.

Installation and setup
You can download Mondo Rescue for free from the Mondo site in RPM, SRPM, DEB, or tar.gz format. Before you begin the actual install process, it’s a good idea to verify that you meet Mondo’s system requirements. This will depend somewhat on how you plan to back up your data. If you will be burning CDs, for instance, you should make sure that the CD burning hardware is up and running before configuring the backup software. The same holds true for other methods, whether NFS or tape. You will also need to make sure that you have the following packages installed (you can download them here):
  • afio—Acts as the archive engine
  • bzip2—Used to compress data
  • cdrecord—Needed for burning CDs
  • ncurses—General screen-handling library
  • newt—An additional library for text mode interfaces
  • lzo—Used to compress data
  • lzop—Used to compress data
  • mkisofs—Makes bootable CD images
  • slang—Similar to ncurses, but provides a programming interface

In addition to Mondo, you will need to obtain the latest Mindi package. Mondo uses Mindi to create boot disks that contain your kernel as well as any modules and libraries. When subsequently used in a backup scenario, this environment will closely match the one you backed up—a great help when you’re short on time and don’t want to waste it tracking down the necessary modules.

Once you have downloaded the appropriate packages, you will need to install them onto your system. For tar.gz Mindi distributions, use the following commands:
tar xvfz mindi-0.80.tgz
cd mindi-0.80
./install.sh

And for RPMs you should be able to install with:
rpm –Uvh mindi-0.80-1.i386.rpm

The process of installing Mondo will be similar, except there is no install.sh script. So once you have unpacked the tarball with the tar xvfz command, you will need to run the ./configure, make, and make install commands.

The software packages should now be installed and ready to run. If you will be using CDs as your backup medium, you should test Mindi to see whether it will create a bootable CD for your system. As root, run the command mindi. You will be presented with a series of options that will allow you to select what to archive. Select y when prompted to make a bootable CD image. Mindi will create the ISO but won’t actually burn it to CD. You will need to run cdrecord manually to do this. The command will be something like the following for CD-RWs:
cdrecord -blank fast dev=0,0,0 speed=2 mindi.iso

And like this for CD-Rs:
cdrecord dev=0,0,0 speed=2 mindi.iso

Once the CD has completed, pop it into a test box, confirm the BIOS is configured to allow bootable CDs, and restart. If you are using cdrecord for the first time or aren’t completely familiar with its options, be sure to read the manpage. Verifying that your hardware and support programs work correctly is an integral part of ensuring the success of a backup.

Backing up
As with any type of system backup, you should choose an unobtrusive time for it to begin. Backups tend to run for long periods of time and can heavily use a server’s I/O. You can look at using cron to kick off your backup early in the morning, for instance, or even configure an incremental, rather than a full backup. Mondo can also make a differential backup, meaning that only files that have changed since the last full backup will be archived. Spend some time planning your backup needs before you begin. This will ensure that you save everything you need but don’t waste valuable resources in the process. See this article for some insights on choosing a backup schedule.

When you are ready to begin your backup, you should be able to get started simply by running mondoarchive on the command line. Mondo will auto-detect most system settings and will prompt you for anything else it needs. Alternatively, Mondo will accept a variety of command line options, useful for automating your backups. Let’s look at the following command, which requires no user input:
mondoarchive -OVw 4 -d 0,0,0 –F

The –O switch tells Mondo to perform a backup of the system. Removable media should be excluded automatically, but everything else will be saved. The switch –V, when used in combination with –O, verifies the backup against the live system once Mondo has finished. This can also be used on its own to compare an old backup with a current system to see what has changed.

In the example above, we will be backing up to a CD-RW, indicated by the –w. You can also back up to CD-R (-c), ISO (-i), NFS (-n), or tape (-t).

Notice the 4 entered after the –w switch. This is the speed of the device in question, in this case a 4x CD burner. Next we have –d, which specifies the device or directory to use for the backup. For CD burners, this will be the SCSI ID of the target drive ("0,0,0," in the example). If you’re not sure what it is, try running cdrecord –scanbus. For ISO or NFS backups, this will be the local or NFS-mounted directory. And the final option, -F, tells Mondo not to ask to make boot floppies. This allows the program to run without manual intervention.

A number of other flags are worth making note of. You can tell Mondo to do a differential backup by passing it a –D flag. The program will check the file system and back up only those files that have changed. You can also use the –E and –I flags to exclude and include specific paths. For instance, if you don't want to back up /tmp and /misc, you can pass mondoarchive the following:
-E "/tmp /misc/"

The paths to omit are separated by a space and enclosed in quotes. The same syntax is used for the –I flag, except the paths will be included. The default path used otherwise is the root directory ("/").

You can run Mondo in GUI mode with the –g flag. This is a nice option if you are running a manual backup or just want to browse through your options. And if you have nonstandard size media, you can use the –s switch, which lets you specify the size of available space. So on a 700-MB CD, for example, you could pass Mondo –s 700m. You can use an m for megabytes or a g for gigabytes.

Restoring
Restoring with Mondo is a relatively easy process. From a standard CD backup, simply put the disc into a bootable drive and reload the system. From here, you will be able to select from one of three modes: Interactive, Nuke, or Expert. Interactive is the most common of the three and allows you to restore step-by-step and/or restore a portion of the archived file system. If you lost one partition or even a single directory, you can restore it via this mode. When booting from the Mondo backup CD, type interactive at the prompt to load this mode.

Nuke is used when there has been a catastrophic loss of data and you need to rebuild from scratch. Please note this will wipe your drives completely and restore everything that was backed up, so use it with caution. To access this mode, press [Enter] at the boot prompt.

Expert mode boots into a shell prompt and allows you to make any manual changes that might be needed. You can also run mondorestore while in this mode to access the onscreen mountlist editor. From here, you can change the outlay of your partitions and even change their formats. For example, you could change a partition from EXT2 to EXT3 format at this prompt and then restore your backup to the new format without any loss of data.

When restoring from other media, like tape or NFS mount, boot using either a bootable floppy or CD and type mondorestore at the prompt. You will then be able to select the type of backup, what files/directories to restore, and the target destination. You can also use Mondo in this way on a live system. If your system is up but missing some backed-up data, execute mondorestore from a root prompt and follow the menu.

Summary
Backing up data is a critical task in any server environment. Mondo Rescue is an open source product that simplifies Linux server backup by offering robust features and ease of use. You can back up your system to a number of different media types, compare a live system with an archived one, and restore all or just part of a file system. It also helps to plan how often you will need to back up your data, how much of it you really need to save, and when you want to perform the backup operation.

 
0 comments