Backing up Android apps and personal data is a good habit, but storing the backup unencrypted on a PC or USB stick exposes you to privacy risks. This tutorial shows how to create a standard ADB backup, then encrypt it with gpg inside Termux – all without rooting the device. By the end you will have a single .ab file wrapped in a .gpg container that only you can open.
What you need
Safety tip: The ADB backup can contain app data that includes passwords or tokens. Keep the unencrypted .ab file only on the phone until it is encrypted, then delete it securely.
pkg update && pkg upgrade -ypkg install gnupg zip unzip tar -y
Why? gnupg provides the gpg command used for encryption; zip and tar help you compress large backups before encryption.
gpg --full-generate-key
The wizard asks for key type, size, expiration and a user ID. For most users the default (RSA and RSA, 4096 bits, never expire) is fine. Remember the passphrase you set – you will need it each time you encrypt or decrypt.
gpg --export -a "Your Name" > mypubkey.asc
Copy mypubkey.asc to your computer via USB, email, or any secure channel.
adb devices
You should see the device serial number followed by device. If it shows unauthorized, check the phone for the RSA prompt.
backup.ab with a name you like:
adb backup -apk -shared -all -f backup.ab
This command backs up installed apps (-apk), shared storage (-shared), and all user data (-all) into a single file. When the phone shows the backup UI, tap Back up my data and, if you want, set a temporary password – you can leave it blank for simplicity.
backup.ab file resides on the computer’s current directory.backup.ab file to the phone’s internal storage (e.g., /sdcard/Download) using the computer:
adb push backup.ab /sdcard/Download/cd /sdcard/Downloadtar -cvf backup.tar backup.ab
You now have backup.tar in the same folder.
tar file for yourself (only you can decrypt). Use the --encrypt flag and specify your own key ID (you can find it with gpg --list-keys):
gpg --output backup.tar.gpg --encrypt --recipient "Your Name" backup.tar
Why encrypt? The resulting .gpg file is AES‑256 encrypted (default) and signed with your private key, guaranteeing confidentiality and integrity.
ls -lh backup.tar.gpg.gpg file, securely delete the unencrypted backup.tar and backup.ab files to avoid leaving plaintext on the device:
shred -u backup.tar backup.ab
If shred is not available, you can install it via pkg install coreutils and then run the same command.
adb pull /sdcard/Download/backup.tar.gpg ~/EncryptedBackups/gpg --import mypubkey.ascgpg --output test.tar --decrypt backup.tar.gpg
If the command asks for the passphrase you set earlier and finishes without error, the encryption is sound.
.ab file to double‑check its integrity:
tar -xvf test.tar
You should see backup.ab. You can now delete test.tar and backup.ab from the test location.
.gpg file back to the phone (or keep it on the computer and use adb restore directly).gpg --output backup.tar --decrypt backup.tar.gpg.ab file:
tar -xvf backup.taradb restore backup.ab
The phone will display a restore UI; follow the prompts to finish.
Common failure: ADB says "device unauthorized"
Make sure you accepted the RSA fingerprint prompt on the phone. If the prompt never appears, toggle USB debugging off and on again, then reconnect.
Encryption step fails with "gpg: no valid OpenPGP data found"
This usually means the public key ID was typed incorrectly. Run gpg --list-keys to copy the exact name or key fingerprint.
Decryption asks for a passphrase you don't remember
Unfortunately, without the passphrase the data cannot be recovered. This is why the tutorial stresses storing the passphrase in a password manager.
Large backups
If your backup exceeds the typical 2 GB limit of some file‑systems, split the encrypted file into chunks using split before moving it to external storage:
split -b 1900M backup.tar.gpg backup.part.
To reassemble, use cat backup.part.* > backup.tar.gpg before decryption.
With these steps you now have a repeatable, root‑free workflow for creating encrypted Android backups that you can store safely on any medium you trust.









