• Edit
  • Delete

Android Backup with adb (Android Debug Bridge, Ubuntu)

This guide was tested with Ubuntu 16.04

Setup

Backup

Open a terminal.

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.

Full backup (all apps, settings and internal storage):

  • adb backup "-apk -all -shared"

I would rather recommend to exclude shared (the internal storage), because the filesize can get very big. You should backup the internal storage via USB connection.

  • adb backup "-apk -all"

Or backup a single app:

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

 

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