Skip to content

About

Android backup extractor

Resources

Stars

2.6k stars

Watchers

52 watching

Forks

Repository files navigation

Android backup extractor

Build and release

Utility to extract and repack Android backups created with adb backup (ICS+). Largely based on BackupManagerService.java from AOSP.

Building

Building requires JDK 17+ (via the bundled Gradle wrapper). The compiled JAR targets Java 8+ bytecode (--release 8).

To create a self-executable all-in-one JAR:

./gradlew shadowJar

Then run:

java -jar build/libs/abe-all.jar pack|unpack|pack-kk ...

Or use the included ./abe wrapper script, which locates build/libs/abe-all.jar automatically.

Running tests

./gradlew test

See Releases for pre-built runnable JAR files.

Usage

Syntax

  • unpack: abe unpack <backup.ab> <backup.tar> [password]
  • pack: abe pack <backup.tar> <backup.ab> [password]
  • pack for 4.4: abe pack-kk <backup.tar> <backup.ab> [password] (creates version 2 backups, compatible with Android 4.4.3)

If the filename is -, data is read from standard input or written to standard output.

If the password is not given on the command line, the environment variable ABE_PASSWD is tried. If no password is specified, the backup archive will not be encrypted, only compressed.

Packing tar archives

  • Android is very particular about the order of files in the tar archive. The format is described here.
  • Incompatible tar archives lead to errors or even system crashes.
  • Apps with the allowBackup flag set to false are not backed up nor restored.
    • (you can try restoring manually via adb push and adb shell)
  • Errors are only printed to logcat, look out for BackupManagerService.

The safest way to pack a tar archive is to extract the exact entry order from the original backup.tar file (excluding directory-only entries ending in /):

tar tf backup.tar | grep -F "com.package.name" | grep -v '/$' > package.list

Then build the new tar archive from the extracted backup directory with --no-recursion so directories in the list are not re-walked (which would duplicate files and break ordering):

tar cf restore.tar --no-recursion -T package.list

On macOS, set COPYFILE_DISABLE=1 to avoid adding AppleDouble (._*) metadata entries, or use POSIX pax instead of BSD tar (which avoids directory entries, trailing slashes, and .DS_Store files):

pax -wd < package.list > restore.tar

If you are building a fresh archive from an extracted apps/ directory on macOS/Linux (note that each package's _manifest file must appear before its data files):

find apps -type f -not -path '*/\.*' | pax -wd > restore.tar

You can now pack restore.tar and try adb restore restore.ab.

Releases

Releases are built with GitHub Actions when a version tag (v*, e.g. v1.0.0) is pushed and include a runnable fat JAR, its SHA-256 checksum, and build provenance attestation.

Use the binaries at your own risk. No warranty or support provided.

Please report only bugs in backup extractor itself; I can't answer questions regarding unpacking/repacking backups or tar files. (See Usage for a mini usage guide.)

Notes

More details about the backup format and the tool implementation in the associated blog post.

About

Android backup extractor

Resources

Stars

2.6k stars

Watchers

52 watching

Forks

Releases

Packages

Used by

Contributors

Languages