An open API service indexing awesome lists of open source software.

https://github.com/xbzzzz/abpy

backup.ab to tar and tar to backup.ab converter python3 script
https://github.com/xbzzzz/abpy

adb adb-backup adb-backups android-ba android-backup

Last synced: 11 months ago
JSON representation

backup.ab to tar and tar to backup.ab converter python3 script

Awesome Lists containing this project

README

          

## about `adb backup`
`adb backup` and `adb restore` are obscure (not mentioned in `adb --help`) and depracated features of `adb` but **no root needed**

`adb backup` and `adb restore` commands documented [here](https://manpages.ubuntu.com/manpages/jammy/man1/adb.1.html)

file generated by `adb backup` is optionally compressed, optinally encrypted tar (pax (kinda) format (don't confuse with `pax` command)) container

files and pax headers in tar archive need to be be in secific order and have specific names, so extracting and creating archive probably won't work (`adb restore` silently fails)

you can `u`pdate files in tar archive without extracting everything using [`7zz` (7-Zip for Linux: console version)](https://7-zip.org/download.html) [`u` command](https://7-zip.opensource.jp/chm/cmdline/commands/update.htm)

here is [help for old version of `7z.exe`](https://7-zip.opensource.jp/chm/cmdline/index.htm) but most command line options are same as `7zz`

## `abpy.py` is python3 script for files generated by `adb backup`
`abpy.py` depends on [pycryptodome](https://pypi.org/project/pycryptodome/) if using `pbkdf2engine=pycryptodome` or `aes256engine=pycryptodome`

`abpy.py` depends on [pycryptodomex](https://pypi.org/project/pycryptodomex/) if using `pbkdf2engine=pycryptodomex` or `aes256engine=pycryptodomex`

## example: modify `/data/data/com.gdpsedi.geometrydashsubzero/CCLocalLevels.dat` on android no root using linux computer


  1. backup com.gdpsedi.geometrydashsubzero's files into backup.ab:
    $ adb backup com.gdpsedi.geometrydashsubzero
    
    WARNING: adb backup is deprecated and may be removed in a future release


  2. convert backup.ab to backup.tar:
    $ python3 abpy.py ab2tar if=backup.ab of=backup.tar


  3. find CCLocalLevels.dat path in list of files in backup.tar:
    $ 7zz l backup.tar | grep -F CCLocalLevels.dat
    
    2023-04-13 11:11:51 ..... 733 1024 apps/com.gdpsedi.geometrydashsubzero/r/CCLocalLevels.dat



  4. extract with full path apps/com.gdpsedi.geometrydashsubzero/r/CCLocalLevels.dat from backup.tar:
    $ 7zz x backup.tar apps/com.gdpsedi.geometrydashsubzero/r/CCLocalLevels.dat

    7-Zip (z) 22.01 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-07-15
    64-bit locale=en_US.UTF-8 Threads:12, ASM

    Scanning the drive for archives:
    1 file, 6880256 bytes (6719 KiB)

    Extracting archive: backup.tar
    --
    Path = backup.tar
    Type = tar
    Physical Size = 6880256
    Headers Size = 14336
    Code Page = UTF-8
    Characteristics = POSIX PREFIX PAX path ASCII

    Everything is Ok

    Size: 733
    Compressed: 6880256



  5. edit apps/com.gdpsedi.geometrydashsubzero/r/CCLocalLevels.dat


  6. update apps/com.gdpsedi.geometrydashsubzero/r/CCLocalLevels.dat to backup.tar:
    $ 7zz u backup.tar apps/com.gdpsedi.geometrydashsubzero/r/CCLocalLevels.dat

    7-Zip (z) 22.01 (x64) : Copyright (c) 1999-2022 Igor Pavlov : 2022-07-15
    64-bit locale=en_US.UTF-8 Threads:12, ASM

    Open archive: backup.tar
    --
    Path = backup.tar
    Type = tar
    Physical Size = 6880256
    Headers Size = 14336
    Code Page = UTF-8
    Characteristics = POSIX PREFIX PAX path ASCII

    Scanning the drive:
    1 file, 824 bytes (1 KiB)

    Updating archive: backup.tar

    Keep old data in archive: 6 folders, 17 files, 6861172 bytes (6701 KiB)
    Add new data to archive: 1 file, 824 bytes (1 KiB)


    Files read from disk: 1
    Archive size: 6880256 bytes (6719 KiB)
    Everything is Ok



  7. get info about backup.ab:
    $ python3 abpy.py abinfo if=backup.ab
    
    ver=5
    compr


  8. convert backup.tar to backup.ab with that info:
    $ python3 abpy.py tar2ab if=backup.tar of=backup.ab compr ver=5


  9. restore the new backup.ab:
    $ adb restore backup.ab
    
    WARNING: adb restore is deprecated and may be removed in a future release
    Now unlock your device and confirm the restore operation.


## stuff I found related to `adb backup`
* https://github.com/nelenkov/android-backup-extractor/
* https://nelenkov.blogspot.com/2012/06/unpacking-android-backups.html
* https://forum.xda-developers.com/t/guide-how-to-extract-create-or-edit-android-adb-backups.2011811/
* https://sourceforge.net/projects/android-backup-processor/files/