Can I use a Time Machine backup to recover deleted Notes that were stored in iCloud? I removed the Notes app from my iPhone and thereby lost all the notes that had been stored in iCloud. (Stupid, I know.) I have a Time Machine backup from shortly before I lost the notes. I've tried restoring the contents of ~/Library/Containers/com.apple.Notes/ and ~/Library/Group Containers/group.com.apple.notes/ but that hasn't worked.

From opening the NoteStore.sqlite file under Group Containers I can tell that at least some of the lost content is in there, but it's hard to make much sense of. I tried opening the same file in an SQLite app but I don't really know what I'm doing and can't find the content that way.

Any suggestions? Thanks.
What is possibly happening is iCloud is overwriting your restore. Be sure sync is turned off before you attempt to restore the database files. Then, manually update Notes and turn sync on so your local copy is the newest one. I believe it will attempt to merge.