Bear.app hourly backup

There’s been a bit of discussion on r/bearapp on the lack of version history in Bear, so I’ve become a little paranoid about my own notes. I came up with a workable (but hopefully temporary) solution using BTT. But there’s got to be a better way.

Anyway, I thought I’d share my script here so the community can either mock me mercilessly or help to make it better:

bear_backup.bttpreset (34.1 KB)

Here it is in action:

Again, there’s got to be a better way to do this! Any other ideas? I’m all ears.

Walking through the BTT steps, conceptually:

  1. If Bear is running, set the value of the variable “BearState” to “open”, else set it to “closed”
  • This is used at the end to either keep Bear open or quit it if it wasn’t running
  1. Show countdown before starting: 3... 2... 1...
  • I found that if it just started running and I was in the middle of typing something, I would inadvertently cancel the script
  1. Ask for input “Ready to back up Bear?” and sets it as a variable “ready”
  • Accepts text input
  • Would have preferred a confirm button, but couldn’t figure out a way to do this in BTT
  1. If “ready” is “y” then start the backup
  • If “ready” is anything else, skip to the end and stop
  1. Use the Bear callback...
  • First use bear://x-callback-url/todo simply to reset any currently selected notes
  • Then use bear://x-callback-url/today to go to today’s notes
  1. Trigger the export via the keyboard command command+shift+S
  2. In the export dialog box, go to my Documents folder with the keyboard command command+shift+O
  3. Type the text “Bear” to find a folder that I made in my Documents folder to store these backups
  4. Trigger the keyboard command command+shift+N to create a new folder in the Bear backups folder named with a timestamp
  5. Type the return key to start the export
  6. Trigger the keyboard command command+[ to go back to the previously selected note
  • If you currently have Bear open and are working on something, running this script will land you in the Today section
  • Triggering Back should get you back to the note that you were on before the script started
  1. If the “BearState” variable from the first step is “Closed”, quit Bear
  • Otherwise, keep Bear open

Worth noting:

  • I’m no BTT pro, but this seems to work for me. YMMV. If you’re a BTT pro, please do help me make it better! It relies on a few steps that could be fragile (like “wait for text to appear on screen”).
  • I tried first to do this with Shortcuts.app but failed. My brain is just incompatible with Shortcuts.app.
  • This exports the text of notes as markdown files. Any attachments or images will not be included. This works for me as my notes are 99% text... but I can understand that this might be a dealbreaker for some.
  • I’ve set it to run every two hours from 9am to 6pm.

I’m not particularly proud of this, but I’ve been running it for a few days and it seems to work for me. I would love for the fine folks at Bear to include a system-level version history function, but until then... well, here we are.

That's all that matters. :slightly_smiling_face:

Maybe I'll create something similar to make a backup of the default preset of BTT.

Edit: I was wondering how you did the countdown. Now I see it ... good idea.