Create the backup (whole)
adb backup -apk -noshared -all -system -f ./my-backup.ab
Create a Single-Package backup
# list the package names adb shell pm list packages # Create a WhatsApp backup (for example), where PACKAGE-NAME is "com.whatsapp" adb backup -f yourbackupfile.ab -noapk com.whatsapp
Extract the files/directories of the backup for query or modification
# strip the first 24 bytes (header) and decompress the raw zlib data with "openssl" dd if=yourbackupfile.ab ibs=24 skip=1 | openssl zlib -d > yourbackupfile.tar # in case you don't have zlib support on your openssl, you can do this: dd if=yourbackupfile.ab bs=1 skip=24 | python3 -c 'import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))' > yourbackupfile.tar # extract the archive tar xvf yourbackupfile.tar
More informatión of how to modify/repack and restore an Android ADB Backup on:
https://stackpointer.io/mobile/android-adb-backup-extract-restore-repack/372/
Restore the backup (any)
adb restore ./my-backup.ab