adb backup is a built-in Android tool that lets you create a local backup of app data, SMS messages, and certain system settings on a Windows, macOS, or Linux PC — no root access required. While Google has deprecated the feature in newer Android releases in favor of Google's cloud backup, it remains functional on most devices through Android 15 and is still the best way to make a local, offline copy of app data before wiping a device.
Before using adb backup, understand these constraints:
android:allowBackup="false") that prevents ADB from backing up their data. Banking apps, authenticator apps, and DRM-protected apps typically block backup. There is no way to override this without root.adb pull for that), and cannot back up the Android system itself.adb backup scope in Android 12. On Android 12 and later, the command still works but backs up fewer app data categories than on older Android versions. For full app data backup on modern devices, root-based tools like ADB-based Titanium Backup alternatives are more effective.With USB Debugging enabled and the ADB connection authorized, run:
adb backup -apk -shared -all -f backup.ab
Flag explanations:
-apk — include the APK files themselves in the backup, not just app data. Useful if you want to reinstall apps without hitting the Play Store.-shared — include files from shared storage (internal SD card). This captures DCIM, Downloads, and similar folders.-all — back up all apps and data (subject to each app's allowBackup setting).-f backup.ab — save the backup to a file named backup.ab in the current directory.A confirmation dialog appears on the phone. You can optionally enter a backup password to encrypt the .ab file. If you set a password, record it — there is no recovery mechanism. Tap Back up my data to start. The terminal shows no progress during backup; wait until the phone screen returns to normal and the .ab file stops growing in size.
To back up only specific apps rather than everything:
adb backup -apk com.example.app1 com.example.app2 -f apps.ab
Replace the package names with the actual app package IDs. You can find an app's package ID with adb shell pm list packages.
SMS messages are stored by the default messaging app. To back them up:
adb backup -noapk com.google.android.apps.messaging -f sms.ab
Replace com.google.android.apps.messaging with the package name of your default SMS app if it is different (Samsung Messages is com.samsung.android.messaging, MIUI Messages is com.android.mms). The -noapk flag skips the APK file and only saves app data, which is all that matters for SMS restoration.
To restore data from a backup file:
adb restore backup.ab
A confirmation dialog appears on the phone. If the backup was encrypted with a password, enter it on the phone (not the PC). Tap Restore my data. Restoration can take several minutes to several hours depending on backup size. The phone must remain connected and unlocked throughout.
Important restoration considerations:
-apk, but if the device refuses installation (e.g., the app is not compatible with the Android version), the data for that app is skipped.adb restore processes the entire .ab file. To extract and restore individual apps, use a third-party .ab file extractor tool.The .ab (Android Backup) format is a custom compressed archive. Its structure is:
apps/packagename/ directory structure.To inspect the contents of an unencrypted backup without restoring it, you can extract it on Linux or macOS with:
dd if=backup.ab bs=24 skip=1 | python3 -c "import zlib,sys; sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))" | tar -tv
This skips the 24-byte header, decompresses the zlib stream, and passes the result to tar for listing. Replace -tv with -xv to extract to the current directory. On Windows, third-party tools like Android Backup Extractor (a Java-based tool available on GitHub) can open .ab files graphically.
For apps that block ADB backup, or for complete device images including system data:
adb pull /sdcard/DCIM ./DCIM_backup."error: device unauthorized": The ADB connection is not authorized. Unlock the phone, check for the authorization dialog, and tap Allow. If no dialog appears, go to Developer Options > Revoke USB Debugging Authorizations, then reconnect.
Backup completes instantly and the .ab file is only a few hundred bytes: This happens when the phone's screen was locked when the backup was started (the confirmation dialog was not tapped). Start the backup again with the phone unlocked and confirm the on-screen dialog within 30 seconds.
"adb: error: cannot backup: no such file or directory" when specifying a path: Ensure the directory for the output file exists. Use a simple filename in the current directory first: adb backup -all -f test.ab. If that works, the path for your intended location has an issue (spaces, missing directory, or permission).
Restore completes but app data is missing: The app was included in the backup with allowBackup="false" or the app data was encrypted with a key tied to the original device. Some apps (Google Authenticator, banking apps) intentionally prevent data migration for security reasons. These apps must be set up fresh.