Skip to content

Instantly share code, notes, and snippets.

@silvae86
Last active May 6, 2024 09:26
Show Gist options
  • Save silvae86/d3d603133827a47355fb39c98ebf877d to your computer and use it in GitHub Desktop.
Save silvae86/d3d603133827a47355fb39c98ebf877d to your computer and use it in GitHub Desktop.
Backup and restore Android partitions to SD Card
#!/sbin/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 Galaxy Note 3
ls -l /dev/block/platform/msm_sdcc.1/by-name/
#for Galaxy Note 3, handles 4GB Limit on SD Card by splitting the backup into 2000MB Parts.
#backup
dd if=/dev/block/platform/msm_sdcc.1/by-name/boot | gzip -c | split -b 2000m - /external_sd/backup_dd/boot.gz.
dd if=/dev/block/platform/msm_sdcc.1/by-name/userdata | gzip -c | split -b 2000m - /external_sd/backup_dd/userdata.gz.
dd if=/dev/block/platform/msm_sdcc.1/by-name/system | gzip -c | split -b 2000m - /external_sd/backup_dd/system.gz.
#restore
cat /external_sd/backup_dd/boot.gz* | gzip -dc | dd of=/dev/block/platform/msm_sdcc.1/by-name/boot
cat /external_sd/backup_dd/userdata.gz* | gzip -dc | dd of=/dev/block/platform/msm_sdcc.1/by-name/userdata
cat /external_sd/backup_dd/system.gz* | gzip -dc | dd of=/dev/block/platform/msm_sdcc.1/by-name/system
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment