Create a Secure Encrypted Backup of Your Android Phone Using ADB and OpenSSL

14 min read Learn a step‑by‑step method to back up Android app data with ADB, encrypt the backup using OpenSSL, and restore it safely without rooting your phone. October 12, 2026 21:00 How to Create an Encrypted Backup of Your Android Device Using ADB and OpenSSL (No Root)

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.

Before You Start

  • USB cable – use a good data cable; a charging‑only cable will not work.
  • Computer with ADB installed – the tutorial covers the installation steps for all major OSes.
  • OpenSSL – most Linux/macOS systems already have it; Windows users can install the binary from the official site.
  • Enough free storage on the computer for the unencrypted backup (it can be several gigabytes depending on installed apps).
  • Battery charge – keep the phone above 50 % or plug it in during the operation.
The method works on Android 4.0 (Ice Cream Sandwich) and newer, but Android 9+ introduced stricter 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.

Step 1 – Install the Android Debug Bridge (ADB)

Windows

  1. Download the Platform‑Tools zip from the Android developer site.
  2. Extract the zip to a folder such as C:\adb.
  3. Add the folder to your PATH:
    setx PATH "%PATH%;C:\adb"
  4. Open a new Command Prompt and run adb version to verify the installation.

macOS

  1. Install Homebrew if you don’t have it: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Run brew install android-platform-tools.
  3. Verify with adb version.

Linux

  1. On Debian/Ubuntu: sudo apt update && sudo apt install android-tools-adb
  2. On Fedora: sudo dnf install android-tools
  3. Check the version with adb version.

Step 2 – Install OpenSSL (if not already present)

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.

Step 3 – Enable USB Debugging on Your Android Device

  1. Open Settings → About phone.
  2. Tap Build number seven times until you see “You are now a developer”.
  3. Return to the main Settings page; you’ll now have Developer options.
  4. Enter Developer options** and enable USB debugging.
  5. If your device runs Android 12 or later, also enable USB debugging (Security settings) to allow ADB to access the backup APIs.

Connect the phone to the computer via USB. When prompted on the phone, tap Allow and optionally tick “Always allow from this computer”.

Step 4 – Verify the Connection

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.

Step 5 – Create a Plain ADB Backup

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.

Do NOT set a password here; we will encrypt the file later with OpenSSL. Leaving it blank avoids double‑encryption and makes the OpenSSL step straightforward.

Step 6 – Encrypt the Backup with OpenSSL

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
If your operating system supports secure deletion (e.g., srm on Linux), use it to overwrite the file before removal.

Step 7 – Verify the Encrypted Backup

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.

Step 8 – Store the Encrypted Backup Safely

  • Copy the backup-encrypted.ab file to an external drive or cloud storage that you trust.
  • Consider splitting the file into parts (e.g., using split) and storing them in separate locations for added resilience.
  • Write down the passphrase in a password manager; losing it means the backup is unrecoverable.

Step 9 – Restoring the Encrypted Backup

When you need to restore, reverse the process:

  1. Decrypt the file:
    openssl aes-256-cbc -d -salt -pbkdf2 -iter 100000 -in backup-encrypted.ab -out backup-decrypted.ab
  2. Connect the Android device and ensure adb devices shows it as device.
  3. Run the restore command:
    adb restore backup-decrypted.ab
    The phone will display a “Restore backup” dialog. Tap Restore my data.
  4. Wait for the process to finish. The device may reboot automatically.
Restoring overwrites existing app data. If you have important data on the phone that isn’t covered by the backup, back it up separately first.

Troubleshooting Common Issues

1. adb devices shows unauthorized

  • Disconnect and reconnect the USB cable.
  • On the phone, go to Developer options → Revoke USB debugging authorizations, then re‑enable debugging.
  • Make sure you tap “Allow” on the prompt that appears after reconnection.

2. Backup stops with “Error: device not found”

  • Some OEMs (e.g., Samsung) use a proprietary USB driver. Install the appropriate OEM USB driver on Windows.
  • Try a different USB port or cable; avoid USB hubs.

3. adb backup creates a tiny file (a few KB)

  • Check whether the apps you expect to back up have android:allowBackup="false" in their manifest. Those apps are intentionally excluded.
  • Make sure you didn’t accidentally use the -noapk flag, which removes APKs and can drastically shrink the file.

4. OpenSSL reports “bad decrypt” when trying to decrypt

  • Confirm you typed the exact same passphrase used during encryption (case‑sensitive).
  • If you added extra spaces or line‑breaks when copying the command, re‑type it manually.
  • Verify the file wasn’t corrupted during transfer (compare checksums with sha256sum).

5. Restoring fails with “Failed to restore data”

  • Make sure the device is running the same Android version or newer than the one used for the backup. Restoring to an older OS can cause incompatibilities.
  • Some apps refuse restoration if the signing certificate changed (e.g., after a major update). In that case you may need to reinstall the app from the Play Store and then restore only its data using the -apk flag omitted.

Advanced Tips

  • Selective backup: Instead of -all, list specific packages with -apk -shared -f backup.ab com.example.app1 com.example.app2. This reduces size and speeds up encryption.
  • Compression before encryption: Pipe the backup through 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.
  • Automating the process: Create a simple shell script (Linux/macOS) or batch file (Windows) that runs the backup, encryption, and cleanup in one click. Remember to store the script securely.

When to Use This Method vs. Full Device Imaging

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.

User Comments (0)

Add Comment
We'll never share your email with anyone else.