Many Android users want a local, offline copy of their apps and personal data that cannot be read by anyone who gains access to the backup file. Cloud services are convenient but raise privacy concerns, and a plain adb backup file is stored in clear text. This guide shows you how to create a fully encrypted backup using only free, open‑source tools, without needing root access.
adb backup command works up to Android 11. On Android 12+ the command is still accepted but may omit some data; the tutorial notes the limitation..enc file.Back up any critical data elsewhere before you begin – the process does not delete anything, but a power loss during the backup could corrupt the temporary files.
adb).C:\platform-tools, and add that folder to your PATH.brew install android-platform-tools or sudo apt install android-tools-adb.abe.jar file to a folder you can easily reference, e.g. ~/tools/abe.openssl version. If missing, install via your package manager (brew install openssl, sudo apt install openssl, etc.).All three tools are command‑line utilities; you will run them from a terminal (Command Prompt, PowerShell, Terminal, or any shell you prefer).
If the dialog never appears, try a different USB port or cable, and ensure the phone’s screen is unlocked.
adb devices
The command should list a single device with the status device. If you see unauthorized, repeat the authorization step in Step 2.
The Android platform still supports the legacy adb backup command. It creates a single .ab file that contains APKs, app data, and optionally shared storage (photos, downloads, etc.).
# Backup all user apps, their data, and shared storage to a file named backup.ab
adb backup -apk -shared -all -f backup.ab
Explanation of the flags:
-apk – include the APK files themselves (so you can reinstall without the Play Store).-shared – include files from the shared storage (DCIM, Downloads, Music, …).-all – back up every installed user app.-f backup.ab – write the output to backup.ab in the current working directory.After you run the command, the phone will display a “Full backup mode” screen asking you to set a password. Leave the password field empty** (just tap Back up my data)** – we will encrypt the file later with a stronger algorithm. If you set a password here, you would need to remember two passwords, which adds unnecessary complexity.
When the backup finishes, you will see a progress bar on the phone and a line like “Backup transport: backup” in the terminal.
The .ab format is a simple wrapper around a tar archive, optionally compressed and optionally encrypted. The open‑source abe.jar tool can unpack it.
# Convert backup.ab to backup.tar (no compression, no password)
java -jar abe.jar unpack backup.ab backup.tar
If you receive a java.lang.OutOfMemoryError, increase the Java heap size:
java -Xmx2g -jar abe.jar unpack backup.ab backup.tar
Now you have a regular tar file that can be inspected with any archive manager.
We will use AES‑256‑CBC, a widely supported symmetric cipher. OpenSSL will ask for a passphrase; choose a strong, memorable one.
# Encrypt backup.tar to backup.tar.enc
openssl enc -aes-256-cbc -salt -in backup.tar -out backup.tar.enc
Explanation:
-aes-256-cbc – the cipher.-salt – adds a random salt to protect against dictionary attacks.-in and -out – specify input and output files.After you type the command, OpenSSL will prompt twice for the passphrase. **Do NOT forget this passphrase** – without it the backup is unrecoverable.
It is good practice to test decryption before you delete the original .tar file.
# Decrypt to a temporary file
openssl enc -d -aes-256-cbc -in backup.tar.enc -out test.tar
# List the contents of the tar to ensure it is intact
tar -tf test.tar | head
If the tar command lists a hierarchy of apps/ and shared/ folders, the encryption/decryption cycle worked.
Once verified, securely delete the unencrypted backup.tar (and the original backup.ab if you no longer need it) using a tool that overwrites the file, e.g. shred -u backup.tar on Linux or a third‑party secure‑delete utility on Windows.
When you need to bring the data back to a device (the same phone after a factory reset or a new device), follow these steps in reverse.
backup.tar.enc to the computer where you have OpenSSL and abe.jar.openssl enc -d -aes-256-cbc -in backup.tar.enc -out backup.tar
.ab file (ADB expects this format):java -jar abe.jar pack backup.tar backup.ab
adb restore backup.ab
The phone will display a “Restore backup” prompt. Tap Restore my data. If the original backup was created with a password (which we avoided), you would be asked to type it now.
adb backup is limited)Starting with Android 12, Google deprecated the full‑device backup capability for security reasons. You can still back up individual apps that expose a run-as shell (debuggable apps) or use the adb pull command on public directories.
com.example.myapp) using adb shell pm list packages | grep myapp.adb shell "run-as com.example.myapp tar -czf /data/local/tmp/myapp.tar.gz /data/data/com.example.myapp"
If the command succeeds, the app is debuggable and you can retrieve the archive:
adb pull /data/local/tmp/myapp.tar.gz .myapp.tar.gz with OpenSSL as described in Step 6.This approach is manual and must be repeated for each app, but it works on newer Android versions without relying on the deprecated adb backup command.
adb devices – Ensure USB debugging is on, the cable is data‑capable, and the phone is unlocked. Restart the ADB server with adb kill-server && adb start-server.ADB_SERVER_SOCKET=localhost:5037 or split the backup: run adb backup -apk -all -f apps.ab and adb backup -shared -f shared.ab separately, then combine later..ab file may be corrupted. Verify its size matches the expected output and re‑run the backup.adb install -r *.apk) and manually copy user files..tar or .ab files on a cloud service without additional encryption. Even though they contain no passwords, they expose personal photos, messages, and app settings.tar -tf check at least once every few months to ensure the file has not degraded.sdelete on Windows, shred on Linux).adb, abe.jar, and openssl on your PC.adb backup -apk -shared -all -f backup.ab.java -jar abe.jar unpack backup.ab backup.tar.openssl enc -aes-256-cbc -salt -in backup.tar -out backup.tar.enc.backup.tar.enc on an encrypted external drive or a trusted cloud vault.adb restore.Following this workflow gives you a portable, password‑protected backup that you control end‑to‑end, without ever rooting the device.
While Android’s built‑in backup service is convenient, it keeps your data in Google’s cloud. The method described here lets you keep a snapshot of your apps and personal files in your own hands, protected by strong AES‑256 encryption. Because the process relies only on official, open‑source tools, it works on virtually any Android phone and can be scripted for regular backups. Remember to keep your encryption key safe, verify backups occasionally, and delete any temporary, unencrypted copies. With these habits, you’ll have peace of mind that your Android data stays private and recoverable whenever you need it.









