Saturday, March 7, 2009

Simple Backup using dd

Backup the whole disk becomes easier with dd command:

1. Fill empty zero till full: "dd if=/dev/zero of=/tmp/delete.me bs=8M; rm delete.me"
2. Invoke the dd command combined with gzip: "dd if=/dev/sda bs=4096 | gzip > /mnt/nfs/diskboot.img.gz"

3. To restore the data from image into the disk, execute: "gzip -dc /mnt/nfs/diskboot.img.gz | dd of=/dev/xxx" (replace /dev/xxx with your target disk)

Warning: Be extra careful when invoking "dd of=/dev/xxx" command since it can wipe out all of your data on your disk if you are pointing to the wrong device.