When you travel, change phones, or simply want a safety net, losing SMS messages, call history or contacts can be frustrating. Android’s built‑in backup options often miss these items or store them in the cloud where you have limited control. This tutorial shows you how to pull the raw SQLite databases that hold SMS, call logs and contacts directly from the device, bundle them into a single archive, and encrypt the archive with openssl. The result is a portable, password‑protected backup that you can store on a computer, external drive, or cloud service of your choice. All steps use standard ADB commands and OpenSSL, so no rooting, third‑party apps, or special device firmware are required.
adb (Android Platform‑Tools) installed and added to your PATH.C:\AndroidBackups or ~/android_backups.Open Settings → About phone → tap Build number seven times until you see “You are now a developer”. Then go back to Settings → System → Developer options and toggle USB debugging on. Confirm any security prompt that appears.
adb devices. You should see a line like XXXXXX device. If the status reads unauthorized, check the phone for a dialog asking to allow USB debugging and tap Allow.When the device appears as device, you are ready to pull files.
SMS messages are stored in /data/data/com.android.providers.telephony/databases/mmssms.db. Because the /data partition is not directly readable, we use adb pull with the run-as trick for apps that allow it, or we use adb backup as a fallback. The most reliable method works on most stock Android devices:
adb shell "run-as com.android.providers.telephony cat /data/data/com.android.providers.telephony/databases/mmssms.db" > sms_backup.db. This streams the file to your current directory.run-as returns “Permission denied”, fall back to adb backup -f sms.ab -noapk com.android.providers.telephony. Then extract the .ab file with openssl (see the optional section at the end).After a successful pull, you will have a file named sms_backup.db on your computer.
The call history lives in /data/data/com.android.providers.contacts/databases/contacts2.db. The same run-as technique works:
adb shell "run-as com.android.providers.contacts cat /data/data/com.android.providers.contacts/databases/contacts2.db" > calllog_backup.db.adb backup approach with the package com.android.providers.contacts.The resulting file calllog_backup.db contains both contacts and call‑log tables. We will later extract only the call‑log portion, but keeping the full database is useful for a complete restore.
Contacts are stored in the same contacts2.db file we just retrieved. To keep the process simple, we will reuse that file for both contacts and call logs. If you prefer a separate copy, repeat the command from step 4 and rename the output to contacts_backup.db.
Having three separate files makes encryption a bit more cumbersome. Use tar (available on macOS/Linux) or 7‑Zip on Windows to create a single archive:
# macOS / Linux
mkdir backup_tmp && mv sms_backup.db calllog_backup.db contacts_backup.db backup_tmp/
cd backup_tmp
tar -cvf ../android_sms_calls_contacts.tar *.db
cd ..
rm -r backup_tmp
# Windows (PowerShell with 7‑Zip in PATH)
mkdir backup_tmp
move sms_backup.db calllog_backup.db contacts_backup.db backup_tmp\
7z a -tzip android_sms_calls_contacts.zip backup_tmp\*
rd /s /q backup_tmp
The resulting android_sms_calls_contacts.tar (or .zip) file contains all three databases.
OpenSSL’s AES‑256‑CBC cipher offers strong symmetric encryption. Run the following command, replacing YOUR_PASSWORD with a passphrase you will remember (quotes are optional but help with spaces):
# Linux / macOS
openssl enc -aes-256-cbc -salt -in android_sms_calls_contacts.tar -out android_sms_calls_contacts.tar.enc -k "YOUR_PASSWORD"
# Windows (PowerShell)
openssl enc -aes-256-cbc -salt -in android_sms_calls_contacts.zip -out android_sms_calls_contacts.zip.enc -k "YOUR_PASSWORD"
After execution you will see a new file ending with .enc. This file is unreadable without the correct password.
It’s a good habit to test decryption before you delete the original unencrypted archive. Run:
# Linux / macOS
openssl enc -d -aes-256-cbc -in android_sms_calls_contacts.tar.enc -out test_decrypt.tar -k "YOUR_PASSWORD"
tar -tf test_decrypt.tar
# Windows (PowerShell)
openssl enc -d -aes-256-cbc -in android_sms_calls_contacts.zip.enc -out test_decrypt.zip -k "YOUR_PASSWORD"
7z l test_decrypt.zip
If the tar -tf (or 7z l) command lists sms_backup.db, calllog_backup.db and contacts_backup.db, the encryption succeeded. You can now safely delete the unencrypted .tar / .zip file.
.enc file to an external hard drive or a cloud folder that you trust.Restoring is essentially the reverse of the backup process. You need the same password and a device with USB debugging enabled.
# Linux / macOS
openssl enc -d -aes-256-cbc -in android_sms_calls_contacts.tar.enc -out android_sms_calls_contacts.tar -k "YOUR_PASSWORD"
# Windows (PowerShell)
openssl enc -d -aes-256-cbc -in android_sms_calls_contacts.zip.enc -out android_sms_calls_contacts.zip -k "YOUR_PASSWORD"
# Linux / macOS
tar -xvf android_sms_calls_contacts.tar
# Windows (PowerShell)
7z e android_sms_calls_contacts.zip
Because the target locations are inside /data, we need run-as again. Run each command separately:
# SMS
adb push sms_backup.db /data/local/tmp/
adb shell "run-as com.android.providers.telephony cat /data/local/tmp/sms_backup.db > /data/data/com.android.providers.telephony/databases/mmssms.db"
# Call logs & contacts (both in contacts2.db)
adb push contacts_backup.db /data/local/tmp/
adb shell "run-as com.android.providers.contacts cat /data/local/tmp/contacts_backup.db > /data/data/com.android.providers.contacts/databases/contacts2.db"
After pushing, you may need to clear the data cache for the affected apps or simply reboot the device so the system reloads the new databases.
run-as fails, you can use adb backup with the -apk flag to restore the entire package, but this will also overwrite other data belonging to the provider.run-as. In that case use adb backup to create a backup file (.ab) and extract it with android-backup-extractor (a Java tool). The extractor is outside the scope of this guide but widely documented.brew install openssl, sudo apt install openssl) or download the Windows binary.By following these steps you gain full control over your personal communication data, protect it with strong encryption, and avoid dependence on cloud services that may change policies or disappear. The workflow works on virtually any Android 6.0+ device, regardless of manufacturer, as long as USB debugging is available.









