Monday, September 26, 2016

adb - Is this the right way to use dd for a full backup?


Sadly my device (sm-g3185) isn't supported by any of the CWM or NANDbackup so I am trying to do a backup manually. I found this thread which tells me to open one terminal (I'm on Arch Linux) and run:


adb forward tcp:5555 tcp:5555
adb shell
su

/system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox dd if=/dev/block/mmcblk0

And then another terminal and run:


adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0.raw

I did all this and it seems to be working. However, there was a delay of a few seconds between launching the dd command in terminal1 and the nc command in terminal2.


Can I trust the backup I created in this way? Doesn't this mean that I've lost some of the output of dd? Shouldn't these be run concurrently or, at least, shouldn't the nc command be started before the dd one?



Answer





Can I trust the backup I created in this way?



Yes, you can: this is the most complete backup that you can make of your device.


The integrity of the copied data can be checked easily by running md5sum on the device (/dev/block/mmcblk0) and comparing its output against the MD5 of the backed up file (mmcblk0.raw).


If you want to list the partitions inside the backup, you can run parted /path/backup/mmcblk0.raw print on the host computer. Inside, you will find your system and userdata partitions and lots of hidden partitions containing bootloader[s], baseband configuration and recovery data among many other things...



There was a delay of a few seconds between launching the dd command on the device and the nc on the host computer. Doesn't this mean that I've lost some of the output of dd?



No, you don't need to worry. When you run nc -l, it will listen for an inbound connection. I the meantime, it will block the pipe and keep dd from sending data. This means that the first byte will be sent by dd once you stablish the connection from the other side.




Shouldn't these be run concurrently or, at least, shouldn't the nc command be started before the dd one?



Not necessarily. As stated on the previous paragraph, you don't need to care about that. dd will only start to send the data once the nc instance running on the device receives the inbound connection from the nc instance running on the host and reads data from the pipe.




Note: you don't need to run adb forward tcp:5555 tcp:5555 twice.


No comments:

Post a Comment

samsung galaxy s 2 - Cannot restore Kies backup after firmware upgrade

I backed up my Samsung Galaxy S2 on Kies before updating to Ice Cream Sandwich. After the upgrade I tried to restore, but the restore fails ...