23

I want to reset my phone but want to recover the system data before doing so. I tried to create a backup with adb and tried to restore it on a virtual device to see if it works. So I tried to restore it with adb on the virtual device and it would say that it fully restored it at the end. But nothing really changed. I wonder if adb backup/restore still works or if I did something wrong.

riQQ
  • 105
  • 6
1789
  • 333
  • 1
  • 2
  • 5

1 Answers1

34

Deprecated means it is fully functional but may be removed in future versions. Google of course prefers that their cloud is used so that they still control access to the backup data.

The only part that seem to have changed by the deprecation is that the help text of adb backup has been removed from the adb binaries. So to show the help text with all options of adb backup you have to execute now: adb shell bu help

However adb backup has a problem with app that disallow backup via it's AndroidManifest.xml. The main problem you don't get any warnings or errors for such apps. hence it is totally unclear if a backup was successful by just looking at the messages printed on the console while creating the backup.

From an app perspective there is also the way to allow only partial backups. By a configuration file the app can specify certain paths or file types to be included or excluded from backup.

Therefore my recommendations is to backup only single apps without APK. Based on the size of the created backup archive you can see if the backup was potentially successful or not.

An alternative is to create a full backup (with or without APKs) and in the end convert the created backup archive using Android Backup Extractor to a tar archive and check that archive for the most relevant apps what files have been backuped.

Update for Android 12+

On Android 12+, apps that have a targetSDK of 31 or higher (are developed for Android 12+) app data backup via adb backup seems to be no longer possible:

For apps that target Android 12 (API level 31) or higher, when a user runs the adb backup command, app data is excluded from any other system data that is exported from the device.

https://developer.android.com/about/versions/12/behavior-changes-12#adb-backup-restrictions

adb backup on Android 12 only work if targetSDK is lower than 31 or the app is marked as debuggable=true. Apps downloaded from Play Store are never debuggable and Google enforces apps to set targetSDK to the latest API level. Therefore apps from Google Play Store that has been updated in 2022 or later should no longer allow app data backup using adb backup.

Robert
  • 20,025
  • 6
  • 47
  • 66
  • How do you backup single apps without the apk as you recommend? Titanium backup? Pull /data/data/com.whatever-app-name? Other ways to do this? – Nomenator Nov 09 '21 at 23:01
  • @Nomenator accessing /data/data requires root permissions so adb pull from that directory requires root permissions + adb root (which itsel requires a patched adb binary). As this answer is about the command adb backup I am wondering why you ask for adb pull instead of trying adb backup for the package name you want to backup. – Robert Nov 10 '21 at 08:10
  • @Robert Sorry, I misunderstood, I was thinking more in line of "what to do when adb backup does not exist anymore?" – Nomenator Nov 13 '21 at 15:47
  • @Nomenator Then only Google cloud backup is left on unrooted devices. – Robert Nov 13 '21 at 15:52
  • 2
    so do i understand this correctly, that there is ... with android 13 ... NO WAY to fully backup your device so it is recoverable after a disaster? I already find it extremely stpd that there is no out of the box way from google themselves like there is with IOS, but it gets even more insane ... – Chris Jan 29 '23 at 10:28
  • @Chris Apple has the advantage that they control bot hard- and software and thus can easily implement a secure backup. On Android there is no way to backup the inner data in a secure way so that it could be restored on a new device without making the data dully accessible to the user. – Robert Jan 29 '23 at 11:20
  • "On Android there is no way to backup the inner data in a secure way" ... i doubt ... there is just no will by anyone who could actually implement it (Google)
    • Plus: now they actually disable adb backup
    – Chris Jan 29 '23 at 16:27
  • @Chris This is not a matter of software but of software and hardware, thus simply implementing it would make Android be able to backup, but at the same time introduce a backdoor where you could access data that should not be accessible by anyone. Securing this requires a hardware anchor which is what Apple did, but Android has no such anchor. – Robert Jan 29 '23 at 18:11
  • @Robert, This doesn't make sense. You have the device physically with you connected to your laptop via usb. So if adb backup doesn't work, surely there can be an (open source) tool that does what it fails to do? – Pacerier Jan 31 '23 at 01:01
  • @Pacerier there are backup solutions for Android but they require a rooted device. Android without root doesn't allow access to app data. Even with the AndroidKeychain is protected by security hardware and can not be extracted or backuped. – Robert Jan 31 '23 at 06:16
  • 2
    "On Android there is no way to backup the inner data in a secure way" Funny that Seedvault manages that. It's a replacement to the Google Cloud backup used with several custom ROMs. It allows you e.g. to store your backups on an external SD card or a cloud service under your control (Nextcloud). As long as you have the pass phrase, you thus could restore at least app backups to any device, and even more to an identical device. TL;DR: enforcing encrypted backups (phrase stored on-device in (hardware) keystore) would be what "secures" backups. – Izzy Feb 07 '23 at 23:17