Home

Awesome

Markdown export and sync of Bear notes

bear_export_sync.py
Version 1.4, 2020-01-11

Python script for export and roundtrip sync of Bear's notes to OneDrive, Dropbox, etc. and edit online with StackEdit, or use a markdown editor like Typora on Windows or a suitable app on Android. Remote edits and new notes get synced back into Bear with this script.

See also: Bear Markdown and textbundle import – with tags from file and folder

Set up seamless syncing with Ulysses’ external folders on Mac, with images included!
Write and add photos in Bear, then reorder, glue, and publish, export, or print with styles in Ulysses—
bears and butterflies are best friends ;)
(PS. The manual order you set for notes in Ulysses' external folder, is maintained during syncs, unless title is changed.)

Suitable for use with https://github.com/andymatuschak/note-link-janitor.

BEAR IN MIND! This is a free to use version, and please improve or modify as needed. But do be careful! both rsync and shutil.rmtree used here, are powerful commands that can wipe clean a whole folder tree or even your complete HD if paths are set incorrectly! Also, be safe, take a fresh backup of both Bear and your Mac before first run.

See also: Bear Power Pack

Usage

python bear_export_sync.py --out ~/Notes/Bear --backup ~/Notes/Backup

See --help for more.

Features

Edit your Bear notes online in browser on OneDrive.com. It has a ok editor for plain text/markdown. Or with StackEdit, an amazing online markdown editor that can sync with Dropbox or Google Drive

Read and edit your Bear notes on Windows or Android with any markdown editor of choice. Remote edits or new notes will be synced back into Bear again. Typora works great on Windows, and displays images of text bundles as well.

NOTE! If syncing with Ulysses’ external folders on Mac, remember to edit that folder settings to .textbundle and Inline Links!

Run script manually or add it to a cron job for automatic syncing (every 5 – 15 minutes, or whatever you prefer).
(LaunchD Task Scheduler Is easy to configure and works very well for this)

Syncs external edits back into Bear

Script first checks for external edits in Markdown files or textbundles (previously exported from Bear as described below):

Markdown export to Dropbox, OneDrive, or other:

Then exports all notes from Bear's database.sqlite as plain markdown files:

You have Bear on Mac but also want your notes on your Android phone, on Linux or Windows machine at your office. Or you want them available online in a browser from any desktop computer. Here is a solution (or call it workaround) for now, until Bear comes with an online, Windows, or Android solution ;)

Happy syncing! ;)