Attack of the Backup: Clonezilla Linux Rampages Over Disaster Recovery

464

 

Disaster recovery and backups are the “eat your vegetables” of the IT world. Most folks just don’t get excited about backups, or do it often enough. Buck the trend with Clonezilla, a Linux distribution that makes it dead easy to clone and restore systems.

Clonezilla is similar to Norton Ghost, but it’s free software (GPL) and it’s good for cloning Linux, Windows, Mac OS X, and UNIX systems — to name just a few. It supports a ton of filesystems, and will resort to direct (dd) copying for filesystems it doesn’t support.

Imaging vs. Backups

Clonezilla images your system — which means that it basically takes a complete snapshot of your filesystem as-is. This has some advantages and disadvantages.

Advantages include being able to go from a blank disk to a restore of your system at the state of the last snapshot. So if your hard drives dies an ugly death, you can slap in a new one, boot the machine using the Clonezilla live CD, and restore your system with a few keystrokes. This is also good if you want to upgrade your laptop or PC to a larger disk or SSD.

Disadvantage? It’s a bit time-consuming and you have to shut the target machine down while you’re doing the clone. This means that you can’t run the clone while you’re using your computer. This means that you’ll probably only want to take snapshots when your computer isn’t in use — like overnight or on Friday before you head home for the weekend.

This means Clonezilla is well-suited for imaging the OS and configuration of personal computers and laptops, and good for imaging server systems before they’re deployed. Using Clonezilla is not a good substitute for daily backups of your data on a personal computer, and no good at all for day-to-day data protection on servers. That doesn’t mean Clonezilla is useless — it’s a great tool to save you from having to hassle with reinstalling an OS and applications from scratch. It’s just not a backup substitute.

On servers, make sure you’re doing regular backups of all system data and configurations. If possible, the best thing to do is to maintain a stock image that you use for installs and update that regularly from a test machine that is similar to production machines.

On PCs/laptops, use Clonezilla to image your machines at least weekly (to keep up with new packages & system updates) and then use one of the dozens of options to back up personal data. I use Dropbox to store all my writing data, and a script to copy the config files (.vimrc for example) that I depend on and change frequently enough to matter.

Using Clonezilla

Clonezilla is available as a live CD and a server edition. If you’re going to be doing a lot of imaging, it might be worth installing the server version. For the purposes of this tutorial, though, I’m going to assume you’re using Clonezilla for one-off backups and restores. If there’s a lot of demand (sound off in the comments!) we’ll cover Clonezilla SE in a later tutorial.

Download the live CD — you’ll notice that the project offers several. I’d choose the stable x86 version, which should be named something like clonezilla-live-1.2.6-40-i686.iso.

You’re going to need one of the following before you make a backup:

  • A server you can SSH to with enough space to store the image.
  • A local disk to store an image to.
  • An NFS or Samba server to store the image on.

In other words, to paraphrase George Carlin, you need a place for your stuff. Whether a local disk, remote server, or something else. For the purposes of this tutorial, we’ll go with SSH server. On the machine that you’ll save the cloned images to, set up an images directory or whatever you’d like — you’ll need it later when you run through the routine using Clonezilla.

The Clonezilla menus are not entirely self-explanatory. Once you’ve booted up, select Start_Clonezilla. Then choose device-image, and then choose one of the Clonezilla modes, local_dev, ssh_server, samba_server, or nfs_server.

Now, you need to set up the network. You can use DHCP, a static configuration, or PPPoE if you happen to be using that. Each of the menus also offers the option to get to a shell prompt.

Once you’ve set up networking, you need to provide the IP address or domain name (FQDN) of the server. What Clonezilla is asking for here is the IP address of the machine you’ll be SSH’ing to, not the address of the machine you’ll be cloning.

Run through the connection to the remote machine — and choose the path that you set up previously for the Clonezilla images. For instance, mine is /home/jzb/images.

Now you can choose between beginner and expert mode. Unless you have a good reason to select expert mode, choose beginner.

More choices — this time, decide what you want to save or restore. You can save the entire disk as an image, or choose specific partitions. You might want to just choose the whole disk unless you don’t have enough room on the server to save the whole disk. Here’s where Clonezilla is really advantageous: Assuming you’re backing up a supported set of filesystems (e.g. a Linux machine, a Windows machine, Mac OS X machine, etc.) it will only save written blocks, not the entire disk. This means, for instance, that backing up the entire disk on a laptop with a 320GB disk with a fresh Linux Mint 10 install and some data from Dropbox only took 12GB.

Give a name for the image, and then press OK. Clonezilla will spend a few minutes, or even an hour or more if you have a lot of data, writing to the new image.

To restore? Simply walk back through the steps, but choose restore from image instead. If all goes well, you’ll have a functional install in no time.

It takes a little time to walk through the Clonezilla procedure, but it’s well worth it. I’ve used it several times to restore systems. I also find it useful to free up systems for testing new distributions — clone the system, then blow away the existing install with a test distro, then restore my familiar and customized distribution when done. I’ve never had a problem with Clonezilla restores, and suggest you make it a part of your weekly routine.