Backing up an Android device is essential, but a plain adb backup file can be read by anyone who gains access to it. By piping the backup through OpenSSL you get strong AES‑256 encryption without ever rooting the phone. This tutorial shows exactly how to create, verify, and restore an encrypted backup using only free tools that run on Windows, macOS, or Linux.
adb backup policies. Some apps (e.g., banking or DRM‑protected apps) deliberately block backup. Those apps will simply be omitted from the final file.Windows
C:\adb.PATH:
setx PATH "%PATH%;C:\adb"
adb version to verify the installation.macOS
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"brew install android-platform-tools.adb version.Linux
sudo apt update && sudo apt install android-tools-adbsudo dnf install android-toolsadb version.macOS & Linux – OpenSSL is typically pre‑installed. Verify with openssl version. If missing, install via your package manager (e.g., brew install openssl or sudo apt install openssl).
Windows – Download the latest binary from Win32/Win64 OpenSSL. Choose the “Light” version, run the installer, and add the bin directory to your PATH.
Connect the phone to the computer via USB. When prompted on the phone, tap Allow and optionally tick “Always allow from this computer”.
Open a terminal (Command Prompt, PowerShell, or your favorite shell) and run:
adb devices
You should see a line with the device’s serial number followed by device. If it shows unauthorized, re‑check the prompt on the phone.
The adb backup command creates a single .ab file that contains app data, shared storage (optional), and the device’s key‑value backup state. Use the following options:
adb backup -apk -shared -all -f backup-unencrypted.ab
-apk – includes the APK files themselves (optional, increases size).-shared – backs up files from the “shared” storage (photos, downloads, etc.).-all – backs up all user‑installed apps.-f – specifies the output file.After issuing the command, the phone displays a “Full backup” dialog. Tap Back up my data and, if you want, set a temporary password (you can leave it blank). The backup process may take several minutes.
OpenSSL can encrypt any file using AES‑256‑CBC, a strong symmetric cipher. Run the following command, replacing mystrongpassphrase with a passphrase you can remember but that is hard to guess:
openssl aes-256-cbc -salt -pbkdf2 -iter 100000 -in backup-unencrypted.ab -out backup-encrypted.ab
You will be prompted twice for the passphrase. The -pbkdf2 flag tells OpenSSL to use the modern PBKDF2 key‑derivation function, and -iter 100000 adds 100 000 iterations to slow down brute‑force attacks.
When the command finishes, you can securely delete the unencrypted file:
rm backup-unencrypted.ab # Linux/macOS
del backup-unencrypted.ab # Windows PowerShell
srm on Linux), use it to overwrite the file before removal.To make sure the file is intact, try decrypting it to a temporary location and checking its size:
openssl aes-256-cbc -d -salt -pbkdf2 -iter 100000 -in backup-encrypted.ab -out test-decrypt.ab
ls -lh test-decrypt.ab
If the size looks reasonable (similar to the original unencrypted file) and no error messages appear, the encryption succeeded. You can now delete test-decrypt.ab.
backup-encrypted.ab file to an external drive or cloud storage that you trust.split) and storing them in separate locations for added resilience.When you need to restore, reverse the process:
openssl aes-256-cbc -d -salt -pbkdf2 -iter 100000 -in backup-encrypted.ab -out backup-decrypted.ab
adb devices shows it as device.adb restore backup-decrypted.ab
The phone will display a “Restore backup” dialog. Tap Restore my data.
adb devices shows unauthorizedadb backup creates a tiny file (a few KB)android:allowBackup="false" in their manifest. Those apps are intentionally excluded.-noapk flag, which removes APKs and can drastically shrink the file.sha256sum).-apk flag omitted.-all, list specific packages with -apk -shared -f backup.ab com.example.app1 com.example.app2. This reduces size and speeds up encryption.gzip to shrink the file, then encrypt:
adb backup -apk -shared -all -f - | gzip > backup.gz
openssl aes-256-cbc -salt -pbkdf2 -iter 100000 -in backup.gz -out backup-encrypted.ab
Decrypt and decompress in reverse order.
The ADB + OpenSSL workflow is ideal when you need a quick, portable backup of app data and you cannot (or do not want to) root the device. If you require a complete image of the internal storage, partitions, or system files, you’ll need a custom recovery (e.g., TWRP) and root access, which is outside the scope of this tutorial.
By following the steps above you gain a reproducible, encrypted backup that protects your privacy and can be restored on any compatible Android device without ever giving third‑party apps access to your raw data.









