Wednesday, December 24, 2008

Easy backups on Linux

Ubuntu has been a fantastic operating system for my desktop and has been my preferred Desktop OS for more than 3 years now. The cool thing about Ubuntu is it's Debian based. So you install once and dist-upgrade to every new release without ever having to reinstall the whole thing. The downside is a dist-upgrade in Ubuntu sometimes fails leaving you with a very b0rken system. That's why I stick with LTS releases for now, because I have little spare time to reinstall my desktop every few months or so. Nevertheless there are brave people out there always keeping track of the latest, more or less stable, version and don't mind the dist-upgrade problems.
Anyway if your install is broken after a dist-upgrade (or any upgrade) it's always nice to have a backup at hand. In search of the ideal, most flexible, backup tool out there I found mondo. So, people, stop asking for a backup tool for Linux on forums, this one will suite your needs.
Unlike some other tools, mondo creates a backup of a live system. It is also capable of creating a set of CD's or DVD's which are bootable and will help you to easily restore your data.
mondo comes with an ncurses based UI to help you easily create backups. I still like the command line version though, so here's my script:
#!/bin/sh
BACKUP_HOME=/home/bu_operator/bkp
BACKUP_TEMP=/home/bu_operator/tmp
BACKUP_PATH=$BACKUP_HOME/`date +%Y%m%d`_myHost
BACKUP_EXCLUDE='/mnt /dev /proc /tmp /home/bu_operator'

mkdir -p $BACKUP_PATH
mondoarchive -Oi -9 -s 4200m -d $BACKUP_PATH -E "$BACKUP_EXCLUDE" -T $BACKUP_TEMP -S $BACKUP_TEMP

The above script will create a live backup (compressed) of the whole system on DVD ISO images. The BACKUP_EXCLUDE variable contains some volatile folders we don't want to be included in the backup.
Restoring the backup is easy. Burn the ISO images on a CD/DVD (or set of CD's/DVD's), boot from the first CD/DVD, select RESTORE and go grab a cup of coffee while mondo is doing the hard work.

No comments: