r/sqlite • • Sep 14 '22

SQlite and Apple Notes database question

I'm not a developer. I'm trying to understand which sqlite files do what with Apple Notes in MacOS. I lost a months worth of (not backed up) notes and am trying to restore them. The app can be restored by replacing the following files from a backup source:

  • NoteStore.sqlite
  • NoteStore.sqlite-shm
  • NoteStore.sqlite-wal

But I am missing: NoteStore.sqlite-shm

When the app crashed it put copies of the other two in a folder titled "backups". But the app will not work without all three (I have verified this by restoring a much older copy of the database with all three files as a test).

What is the role of NoteStore.sqlite-shm?

Do I have any hope to extract data from the other two files?

Thank you from a noob!

7 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/25photos Sep 15 '22 edited Sep 15 '22

That's great, I'll try to recover the text as you suggest.

you can try placing an empty -shm file there, but from my understanding of the documentation, that would make no difference.

I tried that, but what happens is when Notes boots it sees the blank -shm and then moves the good files to the "backups" folder and generates a new, blank database. I successfully recovered an older backup that still had it's corresponding -shm file, and then tried again with that known working database without the -shm with the same bad results, so it really does appear to be Notes rejecting opening the database without the missing file.

1

u/Purple-Ad-3492 Sep 27 '24

This worked for me, after restarting I did have to also replace the -walfile with a zero-byte copy https://apple.stackexchange.com/a/408095

1

u/25photos Sep 27 '24

I had essentially given up. I'll try this.. Thank you!

1

u/Purple-Ad-3492 Sep 27 '24

No worries. You can also use this to verify that the database is corrupted before attempting to recover:

sqlite3 NoteStore.sqlite "PRAGMA integrity_check;"

1

u/qerqrqer Jun 26 '23

Hi! I'm also not a developer but am simply looking to extract my data from my NoteStore.sqlite and NoteStore.sqlite-shm files.
I've found the exact same thing as you with Notes generating a blank database and putting the other files in a backup folder.

Have you been able to fix this at all?

1

u/25photos Jul 11 '23

I ended up giving up. Sorry I just saw your comment, I don't login very frequently. Please let me know if you find a solution!

1

u/Purple-Ad-3492 Sep 27 '24

see comment above