Clone a Hard disk before making changes to it is a great way to be sure you can go back to the previous state.
I usually do that before a major Linux upgrade on my servers, if something brokes during the update I can easily go back.
And the command is as easy as: <p class="codigo">dd if=/dev/hda of=/dev/hdb</p>
Where if is the input media and of is the output media, be sure to avoid mistakes, as you can ruin your hard disk.
Backup to an image
If you prefer you can also save to an image, instead of using a whole disk as the target.
dd if=/dev/sda of=~/backup-disk-YY-MM-DD.img
If you want to store it on a CD or DVD, just follow this way.
First compress it
Burn the image on the CD/DVD
cdrecord -v speed=8 dev=0,0,0 name_of_iso_file.iso
You may want to check this out Burn ISO images
To restore the images, just exchange the if and of targets.
dd if=~/backup-disk-YY-MM-DD.img of=/dev/sdaNote: Be sure to, not mess with /dev/sda, /dev/hda, /dev/sda1.. etc... you can check the mounted points using the command
df. It may have an output like this:
Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda3 74786624 57024748 13962908 81% / /dev/hda1 101086 36808 59059 39% /boot none 513256 0 513256 0% /dev/shmOr maybe like this:
/dev/disk/by-uuid/fc8f5296-7bd8-463a-87af-87c6d2215ff9 42034200 15579204 24319972 40% /If this happens, and
/etc/fstabis by UUID check this Linux UUID