Backup/Restore SMS/MMS via ADB on a non-rooted device? Is there any way to backup/restore SMS and MMS messages using ADB, when the device is not rooted?


adb pull won't work here, as the corresponding database (/data/data/com.android.providers.telephony/databases/mmssms.db) cannot be read by ADB if it's not running in insecure (root) mode
adb shell "cat /data/data/com.android.providers.telephony/databases/mmssms.db &gt; /sdcard/mmssms.db doesn't work either without root access
adb backup for some reason doesn't cover this database on the device I've checked with (empty backup – just the 41 bytes of the backup header in the resulting file)


I especially wonder why adb backup doesn't cover this. If it's for "privacy reasons", then the same should apply to the contacts database – which clearly is backed up.

References:


Can adb be used to recover SMS messages while in permanent “Safe Mode”? covers the same topic – but other than there, I'm not restricted to safe-mode
backup full sms/mms contents via adb (on our developers sister-site) is for a "rooted solution" (and, apart from that, a bit of age: question and answers are more than 3 years old)


So: Any solution on a non-rooted device? Note that I'm NOT asking for an app-based solution. I'm fully aware there are several apps available for this. I specifically want a "shell based solution", to be used via ADB.
I especially wonder why adb backup doesn't cover this.

It is not that adb backup doesn't want to cover the app com.android.providers.telephony. This app is not much different from any other system app based on its AndroidManifest.xml. The problem is with the flag its developer has declared in the manifest which as a default mechanism for some reason adb backup is bound to respect.
This flag is none other than android:allowBackup=&quot;false&quot;. It opts out the app from both ADB backup and restore. Google here has to say:

android:allowBackup
Whether to allow the application to participate in the backup and restore infrastructure. If this attribute is set to false, no backup or restore of the application will ever be performed, even by a full-system backup that would otherwise cause all application data to be saved via adb. The default value of this attribute is true.

(Emphasis mine)
Checkout the AndroidManifest.xml of this app for Lollipop version here, or see this evidence for my Android 4.2.1:

There's more to this app. You can't even Clear Data from Settings → Apps → All apps →&lt;THIS_APP&gt; since android:allowClearUserData=&quot;false&quot; is declared too, not something we encounter every now and then.

If it's for &quot;privacy reasons&quot;, then the same should apply to the contacts database – which clearly is backed up.

It's bizarre, not that you're able to do it but how is your  system even allowing you to do that just with adb backup!
Contacts storage is handled by &quot;ContactsProvider&quot; app which goes by the pkg_name=com.android.providers.contacts. The flag android:allowBackup=&quot;false&quot; is clearly mentioned in its AndroidManifest.xml for Jelly Bean (click here to see for the other versions).
Are you using ICS or any predecessor of JB?
I found that this app doesn't have any declaration of that flag for ICS here. You can actually  clear this mystery, since I can't take backup of this app in my JB 4.2.1 as per the definition of the flag, and always gets that 41 bytes backup file.

As for any other method to take SMS/MMS backup/restore using ADB without root access -- all hands up here.