I am going to use the omnipresent and omnipotent tool called dd to back up a hard drive partition. I am working with the drive /dev/sdb. First, I save a text file that has information on the partition table layout.
fdisk -l /dev/sdb > hdpt.txt fdisk -l -u /dev/sdb >> hdpt.txt
Then, I choose the compression format to use for the backup archive.
My choice for the compression format is lzma which provides superior compression and faster decompression. The following command backs up a partition at /dev/sdb1 with dd and lzma.
dd if=/dev/sdb1 | lzma -9c > backup01.bin.lzma
To restore this backup later, use the following command:
lzcat backup01.bin.lzma | dd of=/dev/sdb1