Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
4
rated 0 times [  4] [ 0]  / answers: 1 / hits: 19964  / 1 Year ago, mon, january 9, 2023, 5:32:27

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:




  1. I need to backup /dev/sda6 and store that as an image (.img) file in /dev/sdb3


  2. 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

More From » backup

 Answers
0

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:




  1. Find out where /dev/sdb3 is mounted. Use the mount command for this. Assume that /dev/sdb3 is mounted in /home.

  2. Point your file writing to that place:



    sudo dd if=/dev/sda6 of=/home/backup.img

  3. 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.


[#25410] Monday, January 9, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
lasagnerhead

Total Points: 487
Total Questions: 105
Total Answers: 122

Location: French Southern and Antarctic Lands
Member since Sun, May 3, 2020
4 Years ago
;