Restoring a deleted note in Apple's notes app

31 August 2014

I recently deleted a note on my Notes app on my apple laptop. As someone who is a paranoid keeper of backups, and usually commits all my work to a repository like git, I don't worry much about accidental deletion. But Apple's notes app doesn't have any form of version control, and it's all too easy to delete something by accident. I have a daily rsync backup and run time machine, but googling couldn't uncover a simple way of getting the note back. So in case someone else needs to do this, here's what I did.

First I needed to find where Notes stores its data, googling around told me that it was in ~/Library/Containers/com.apple.Notes/Data/Library/Notes/[1]. However doing a restore from Time Machine didn't help, because iCloud helpfully overwrote the restored version with one that was up to date. The data is also really mangled, so I couldn't easily just find the text I needed with a text editor.

So I did this:

In hindsight, however, it may have been easier to just disconnect my main laptop from the internet, restore from time machine, copy the text I needed from the notes app, and then reconnect. But I don't have the inclination to try to see if that works.

I don't store anything important in the notes app, preferring Evernote, or files in the safety of a git repository. I wish people who build software applications would make versioning a regular part of their feature set, once you get used to it, it's hard to live without it.


Footnotes

1: This stack exchange implies that some data may be elsewhere too, although I found what I wanted in the path I gave.