There're several ways to accomplish this, if you want an image of your complete installation and have a secondary hard disk (or a network location) as destination, then assuming your installation is on /dev/sda (in this example boot might be /dev/sda1, swap is /dev/sda2, root is /dev/sda3) and your secondary hard disk or network location is mounted at /mnt/backup
dd if=/dev/sda1 | bzip2 -9 > /mnt/backup/boot-image.bz2
dd if=/dev/sda3 | bzip2 -9 > /mnt/backup/root-image.bz2
dd if=/dev/sda count=512 > /mnt/backup/sda.mbr
You'll notice that swap is left out.
To restore the image, you'd boot using a livecd or similar, mount the backup location then run:
# caution this will erase /dev/sda
dd if=/mnt/backup/sda.mbr of=/dev/sda
At this point /dev/sda's partition, table should be restored & visible when you run:
fdisk -l
So you can restore with:
bzcat /mnt/backup/boot-image.bz2 | dd of=/dev/sda1
bzcat /mnt/backup/root-image.bz2 | dd of=/dev/sda3
mkswap /dev/sda2
Remove your bootable media, reboot and your system has been restored
However, it's often not preferable to image large filesystem because garbage in the free space will be included, I'd recommend you skip the steps for sda3 above and instead to backup use:
cd /; tar -cjf /mnt/backup/root.tar.bz2 / -X /tmp/exclude.txt
You would obviously first need to create /tmp/exclude.txt which should list locations to exclude from the backup, for example:
/dev/*
/proc/*
/sys/*
/tmp/*
/mnt/*
Then to restore from your LiveCD or whatever:
mkfs.ext3 -L root /dev/sda3
mkdir /mnt/restore; mount /dev/sda3 /mnt/restore; cd /mnt/restore
tar -xjvpf /mnt/backup/root.tar.bz2
Or using rsync, in which case just create the filesystem & mount it as above & then rsync the contents back.