-
-
Save derjohn/cfa29a33a051fd4500c5534f76d4c2ec to your computer and use it in GitHub Desktop.
Backup and restore Android partitions to SD Card
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#open adb shell | |
adb shell | |
#listing partitions (general command for Android devices) | |
#ls -l /dev/block/platform/<block_device_name>/by-name/ | |
#for the ZTE Axon7 | |
ls -l /dev/block/platform/soc/624000.ufshc/by-name/ | |
# handles file size limit on e.g. FAT partitions with blit | |
#backup via ADB | |
adb shell 'dd if=/dev/block/platform/soc/624000.ufshc/by-name/boot' | gzip -c | split -b 2000m - /path/to/backup/on/localmachine/boot.gz. | |
adb shell 'dd if=/dev/block/platform/soc/624000.ufshc/by-name/userdata' | gzip -c | split -b 2000m - /path/to/backup/on/localmachine/userdata.gz. | |
adb shell 'dd if=/dev/block/platform/soc/624000.ufshc/by-name/system' | gzip -c | split -b 2000m - /path/to/backup/on/localmachine/system.gz. | |
# No idea if it possible to reinject them, but save .... | |
adb shell 'su -c dd if=/dev/block/platform/soc/624000.ufshc/by-name/cryptkey' > /path/to/backup/on/localmachine/cryptkey.dd | |
adb shell 'su -c dd if=/dev/block/platform/soc/624000.ufshc/by-name/keystore' > /path/to/backup/on/localmachine/keystore.dd | |
adb shell 'su -c dd if=/dev/block/platform/soc/624000.ufshc/by-name/keymaster' > /path/to/backup/on/localmachine/keymaster.dd | |
#restore: cat | adb shell does not work properly (it doesnt find end of stream) | |
#This example is only userdata | |
adb forward tcp:9999 tcp:6666 | |
adb forward --list # you should see port 9999 listening in localhost | |
adb shell 'nc -l -p 6666 > /dev/block/platform/soc/624000.ufshc/by-name/userdata' | |
cat /path/to/backup/on/localmachine/userdata.gz.* | gzip -dc | nc 127.0.0.1 9999 | |
# To follow the progress on your local machine, open a new shell and ... | |
sudo apt install progress | |
progress -m | |
# Recovery speed is about 3.0 MiB/s remaining ...loooong.... that's about 5 min per GB, the Axon das 56GB userdata .... ZzZzzZzzzZ ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment