Search code examples
iosdatabasesqlitemessage

Merging/migrating sms.db sql database from iOS 10 to iOS 12


I have an sms.db dating back to 2012 on an iPhone 5 which was until recently on iOS 6. Having had a forced upgrade to iOS10, I was surprised to find the sms database stayed intact and accessible by the new OS. I now need to move this db to iOS 12.

First I simply moved the original sms.db - it was marked as incompatible as below:

.incompatible10113 (iOS 10 client version)

string being added to the file extension

That was "fixed" (or I thought so) by editing the ClientVersion string directly in the db properties to 12005 (which is what I got the from the original iOS 12 db). I also moved the Attachments, Drafts and Parts folders setting permissions.

The OS now accepts the db (as in, it doesn't get deleted/renamed), however doesn't seem to be able to read it/use it. I've tried setting permissions to 0644, 0750 and 0755, and the owner is set to mobile.

The main sms.db file stays in place, a sms.db-shm file is created (standard 33kb), but the in-use write-ahead log of the db, sms.db-wal, stays at 0 bytes even after several reboots. It gets written to when a new message is received, and Messages.app displays the new message only. Attempts to search in messages have shown some older entries (potentially cached somewhere other than /Library/SMS), which have since disappeared, and also wiped the newly received messages from view.

Would anyone know whether there is a new schema for sms.db in iOS12, and if so how to make the old db compatible? Alternatively, how would I go about merging those two sqlite databases? Thanks


Solution

  • not sure how much of this is accidental, but I managed to restore it:

    • copied the full iOS 10 SMS folder (including wal/shm database files)
    • pasted into a freshly created SMS folder on iOS 12 - rename the old SMS folder to SMSold or something more creative
    • set the permissions on the folder as on the original folder (mobile/mobile owners; 644)
    • set the same permissions on the files inside (especially the db files - sms.db and its appendices)
    • reboot and hope somehow, this worked. iOS seems to have "upgraded" the iOS 10 db itself (ClientVersion property is now 12005), and there are some new tables in the main db file.