Automated backup script

Shaun Kane's Avatar

Shaun Kane

09 Jan, 2017 05:49 PM

I have really been enjoying using Bear, but feel nervous using any service for which I don't have automated backups. I looked around for an automated backup solution, but couldn't find anything, so I hacked together something to make this work.

This script takes the text content from each note and exports it into a plain text file with a .md extension at the specified directory. I have been using this to back up my note text to a folder in Dropbox. I was having trouble getting Dropbox to back up files with unicode in the titles, so this script currently removes any unicode characters from the note title, but not from the note body. You can use an app like Lingon X to schedule an automated backup of your notes.

This is a very hacky solution to the problem, but may be a useful stopgap for some until Bear can produce scheduled backups. Please use this at your own risk - it's possible that this could mess up your Bear database, and future updates to Bear may break the script. Also, this currently only backs up note text, and does not know how to deal with any other types of content.

Here is the URL for the script again: I tested this using Python 2.7.11 on macOS 10.12.2.

  1. 1 Posted by wally_bear on 10 Jan, 2017 05:46 AM

    wally_bear's Avatar

    I recently saw another thread about a user using Time Machine. I wonder how the combo of syncing with iCloud, and accidentally delete something (that already got synced), and using something like Time Machine, or CrashPlan would work? It might be easier that using the script since CrashPlan, Time Machine, etc..., work in the background at set intervals? Thoughts?

  2. Support Staff 2 Posted by Danilo Bonardi on 10 Jan, 2017 09:08 AM

    Danilo Bonardi's Avatar

    Hi Shaun,

    really cool script!

    We have plans to build an automated backup solution inside Bear, but right now is not top priority.

    If you want to you can post your script on reddit, I think more people would be interested:


  3. 3 Posted by Alan on 09 Jan, 2018 08:08 PM

    Alan's Avatar

    This works well, although the notes database is now at '/Users/<username>/Library/Containers/net.shinyfrog.bear/Data/Documents/Application Data/database.sqlite'

    I extended this to do also backup my attachments- does a simple file copy from '/Users/<username>/Library/Containers/net.shinyfrog.bear/Data/Documents/Application Data/Local Files' to my EXPORT_DIR

    I found a more complicated approach at but I prefer this simple approach.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac