Secure Encrypted Backup of Android App Data Using ADB and OpenSSL

15 min read Step‑by‑step guide to back up Android app data with ADB, convert it to a tar archive, encrypt it using OpenSSL, and restore safely without root. October 05, 2026 13:00 How to Create a Secure Encrypted Backup of Android App Data Using ADB and OpenSSL (No Root)

Losing app data can be frustrating, especially when the data contains personal notes, game progress, or confidential work files. While Google Drive or manufacturer cloud services offer convenience, they don’t give you full control over encryption and storage location. This tutorial shows you how to create a **complete, encrypted backup of every app’s data** using only ADB (Android Debug Bridge) and OpenSSL – no root required.

Why use this method? It gives you three advantages:
  • Portability: The backup is a standard .tar archive that can be moved between computers.
  • Strong encryption: OpenSSL’s AES‑256‑CBC with a salt protects the file even if the storage medium is stolen.
  • Zero‑root requirement: Works on any Android 5.0+ device that allows ADB backup.

Before You Start

  • PC with ADB installed: Follow the official platform‑tools download page.
  • OpenSSL installed: Windows users can use Git Bash or Chocolatey (choco install openssl). macOS and Linux usually have it pre‑installed.
  • USB debugging enabled: Settings > About phone > tap Build number seven times, then Settings > System > Developer options > USB debugging.
  • Charge level > 50 %: A full backup can take several minutes and consume noticeable power.
  • Enough storage on the PC: The backup size is roughly the amount of data stored on the device (often 2‑3 GB for a typical user).
Safety note: The ADB backup format (.ab) can contain unencrypted app data if you skip the encryption step. Always keep the encrypted file in a secure location.

Step 1 – Verify ADB Connection

  1. Connect the phone to the PC via a USB‑C or micro‑USB cable.
  2. Open a terminal (Command Prompt, PowerShell, Terminal, or Git Bash) and run:
    adb devices
    You should see a line like 0123456789ABCDEF device. If the status is unauthorized, check the phone for a dialog asking to Allow USB debugging and tap Allow.
  3. Optional sanity check – pull the device’s model name:
    adb shell getprop ro.product.model
    This confirms you’re talking to the right device.

Step 2 – Create a Full ADB Backup

The built‑in ADB backup command packages app APKs, shared storage (photos, downloads) and the app’s private data into a single .ab file.

  1. Decide on a destination folder, e.g. C:\Backups\Android (Windows) or ~/Backups/Android (macOS/Linux).
  2. Run the following command, adjusting the path as needed:
    adb backup -apk -shared -all -f "C:\Backups\Android\full_backup.ab"
    • -apk – includes the original APK files (useful if you later want to reinstall without Play Store).
    • -shared – backs up the contents of /sdcard (photos, downloads, etc.).
    • -all – backs up every user‑installed app.
    • -f – specifies the output file.
  3. When the command runs, the phone will display a “Full backup mode” screen. You will be asked to set a password for the backup. Leave the field blank** if you intend to encrypt later with OpenSSL** – a blank password tells ADB to produce an unencrypted .ab file, which we will encrypt ourselves.
  4. Tap Back up my data. The process may take several minutes; you’ll see a progress bar on the device.
  5. When the backup finishes, you’ll get a confirmation dialog. Press OK and disconnect the phone.
Tip: If you only need specific apps, replace -all with -package com.example.app1 -package com.example.app2.

Step 3 – Convert the .ab File to a Standard .tar

The ADB backup file is a custom format that starts with a 24‑byte header, followed by the raw .tar data (optionally compressed). Converting it makes the archive compatible with OpenSSL and other tools.

  1. Open a terminal and navigate to the folder containing full_backup.ab.
    cd "C:\Backups\Android"
  2. Run the conversion command:
    dd if=full_backup.ab bs=24 skip=1 | openssl zlib -d > full_backup.tar
    • dd skips the 24‑byte header.
    • openssl zlib -d decompresses the payload (ADB uses zlib compression by default).

    If you get openssl: command not found, make sure OpenSSL is in your PATH.

  3. Verify the conversion by listing the archive’s contents:
    tar -tvf full_backup.tar | head
    You should see a list of files such as apps/com.example.myapp/....

Step 4 – Encrypt the .tar with OpenSSL

Now we’ll protect the archive with AES‑256‑CBC. The command prompts you for a passphrase – choose a strong, memorable password or store it in a password manager.

  1. Run the encryption command:
    openssl enc -aes-256-cbc -salt -in full_backup.tar -out full_backup.tar.enc
    • -aes-256-cbc – the encryption algorithm.
    • -salt – adds a random 8‑byte salt, making dictionary attacks harder.
  2. When prompted, enter and confirm your passphrase. OpenSSL will write full_backup.tar.enc to the same folder.
  3. Delete the unencrypted intermediate files to avoid accidental exposure:
    del full_backup.tar   # Windows
    rm full_backup.tar    # macOS/Linux
Important: If you forget the passphrase, the data is unrecoverable. Keep the password in a secure password manager.

Step 5 – Verify the Encrypted Backup

It’s a good habit to test decryption before you rely on the backup.

  1. Copy full_backup.tar.enc to a temporary folder.
  2. Decrypt it back to a test .tar:
    openssl enc -d -aes-256-cbc -in full_backup.tar.enc -out test_restore.tar
  3. List the contents of test_restore.tar:
    tar -tvf test_restore.tar | head
    If the list appears correctly, the encryption/decryption cycle works.
  4. Delete the test file:
    del test_restore.tar   # Windows
    rm test_restore.tar    # macOS/Linux

Step 6 – Restoring Your Data

When you need to bring the data back to a device, follow the reverse process.

  1. Decrypt the archive:
    openssl enc -d -aes-256-cbc -in full_backup.tar.enc -out full_backup.tar
  2. Re‑package the .tar into an .ab file:
    printf "ANDROID BACKUP\n1\n\0\0\0\0" | cat - full_backup.tar > full_backup.ab
    The printf line writes the 24‑byte header required by ADB. The header fields are:
    • Magic string ANDROID BACKUP
    • Version 1
    • Compression flag 0 (no compression because we already have a plain tar)
    • Four zero bytes for future use
  3. Connect the target device and enable USB debugging.
  4. Run the restore command:
    adb restore full_backup.ab
    The phone will show a “Restore data” screen. If you set a password when the backup was originally created (you didn’t in this tutorial), you’ll be asked to enter it now.
  5. Confirm the restore and wait for the progress bar to finish. After the device reboots, the apps and their data should be exactly as they were at backup time.

Troubleshooting Common Issues

1. ADB reports “backup failed” or the device shows a blank screen

  • Check the backup password: If you accidentally entered a password during the ADB backup step, the resulting .ab file is encrypted. The conversion command in Step 3 will fail because OpenSSL expects raw data. Either redo the backup without a password or use the androidbackup tool to decrypt it.
  • Device policy restrictions: Some OEMs (e.g., Samsung Knox) block ADB backup for certain apps. You can still back up user‑installed apps that are not flagged as “protected”.
  • Insufficient storage on the phone: ADB needs free space equal to the size of the data being backed up. Free up at least 1 GB before starting.

2. dd: cannot skip 24 bytes or openssl: error:06065064

  • Make sure you’re running the command in a shell that supports dd (Git Bash, Cygwin, macOS/Linux). Windows cmd does not have dd built‑in.
  • If you prefer a pure‑Windows solution, download the free android-backup-extractor.jar and run:
    java -jar abe.jar unpack full_backup.ab full_backup.tar
    This tool does the same header‑skip and decompression work.li>

3. Decryption fails with “bad decrypt”

  • Verify you’re using the exact same password you entered during encryption.
  • Check that the file wasn’t corrupted during transfer (e.g., via email). Compare MD5 hashes before and after copying:
  • openssl md5 full_backup.tar.enc

4. Restoring shows “restore failed” on the device

  • Make sure the .ab header you recreated matches the format expected by the device (the printf command above is the safest method).
  • If the device runs Android 12+ and the backup contains apps that target API 30+, the system may refuse to restore data for apps that have changed their android:allowBackup attribute to false. In that case you’ll need to back up those apps individually with adb pull /data/data/…, which requires root.

Alternative Approaches

If the ADB backup method feels too heavyweight, consider these options:

  • Encrypted ZIP: After extracting the .tar, compress it with zip -e (or 7‑Zip) to get a password‑protected archive. This is less robust than OpenSSL’s AES‑256, but easier on Windows.
  • Third‑party backup apps: Apps like Swift Backup or Titanium Backup (root required) provide UI‑driven encryption.
  • Cloud sync + end‑to‑end encryption: Store the .tar in a cloud folder encrypted with rclone crypt. This adds off‑site redundancy.

Security Best Practices

  1. Use a unique, high‑entropy password: At least 12 characters, mixing upper/lower case, numbers, and symbols.
  2. Store the encrypted file on an encrypted drive: BitLocker (Windows), FileVault (macOS), or LUKS (Linux) adds a second layer.
  3. Keep multiple copies: One on an external SSD, another on a USB flash drive stored in a fire‑proof safe.
  4. Rotate backups regularly: Create a new encrypted backup every month and purge older copies after verifying the new one works.

Putting It All Together

By following the six steps above you gain a portable, strongly encrypted snapshot of every app’s data on your Android device. The workflow is deliberately split into three logical phases – capture (ADB backup), transform (convert to tar), and protect (OpenSSL encryption) – so you can swap out any part if your environment changes. Whether you’re safeguarding game progress, business notes, or a personal finance app, this method gives you full control over where the data lives and who can read it.

Remember: backups are only useful when they’re restorable. Test the decryption and restore process at least once after creating a backup, and keep the encryption password safe. With these habits in place, you’ll never have to worry about losing critical Android app data again.

User Comments (0)

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