How can I backup a partition (not the whole disk) to another partition on an external hard-disk using DD?
I achieved this with the following command:
sudo dd if=/dev/sda6 of=/dev/sdb3 bs=1M
However my requirements are:
-
I need to backup
/dev/sda6
and store that as an image (.img
) file in/dev/sdb3
-
Preferably as a compressed (.gz) image file (this is actually what I am trying to achieve)
(Here are my foolish attempts that, obviously, didn't work:
sudo dd if=/dev/sda6 of=/dev/sdb3/backup.img bs=4096 conv=notrunc,noerror
sudo dd bs=1M if=/dev/sda6 | gzip -c > /dev/sdb3/backup.gz
Best Answer
Unless
/dev/sdb3
is actually mounted on/dev/sdb3
( I doubt it, please research a bit on devices and mount points), you'd need to:/dev/sdb3
is mounted. Use themount
command for this. Assume that/dev/sdb3
is mounted in/home
.Point your file writing to that place:
Once done, verify the img file contains what you expect.
Also, is there any need to back up the entire partition? I usually find it easier and more useful to back up files using
rsync
or something similar, then if needed compressing the resulting backup directory. But this is really up to you.