• Edit
  • Delete

Android Backup with adb (Android Debug Bridge, Ubuntu)

This guide was tested with Ubuntu 16.04 and 18.04

Installation of required tools

Actual Backup

Note that "adb backup" creates "backup.ab" file in the current working directory. So create a separate directory for each of your backups to avoid overwriting "backup.ab" accidentally.

  • Open a terminal.
  • Create a separate directory, example:
    • mkdir android_adb_backup_2020-03-03
    • cd android_adb_backup_2020-03-03

I recommend to exclude the internal storage ("-shared" option). Better backup the internal storage by copying the files.

  • adb backup -apk -all

Or create a full backup (all apps, settings and internal storage):
Warning: the filesize can get very big. I recommend to backup the internal storage by copying the files in explorer.

  • adb backup -apk -all -shared

Or backup a single app:

  • adb shell 'pm list packages'
    • ...
      package: com.vendor.appname
      ...
  • adb backup -noapk com.vendor.appname

Note: there is some confusion if, and what kind of quotes are needed for the adb backup options (adb backup "-apk -all" ?)

Restore

Theoretically you could simply restore a complete backup (adb backup "-apk -all -shared") but I don't think it would make sense in many cases.

I like to select specific apps to restore. That is easy when you backed up only one app with "adb backup -noapk com.vendor.appname":

  • adb restore backup.ab

But this is quite tedious. The best way I found is the following:

Best Practice

  • Create a full backup without shared ("adb backup "-apk -all")
    • adb backup "-apk -all"
  • Split the backup with android-backup-toolkit:
    • cp ~/bin/android-backup-tookit/abe.jar .
    • cp ~/bin/android-backup-tookit/tar-bin-split.jar .
    • ~/bin/android-backup-tookit/adb-split-no-extraction.sh backup.ab
  • Now there is a separate .ab backup file for each app in split-ab/ directory.
    • ls -l split-ab/
  • Restore the apps of your choice with
    • adb restore split-ab/com.vendor.appname