Self-Hosting Obsidian Backups

#self-hosting #guide #backups #obsidian

I use Obsidian to store all my notes (not because I'm a Zettelkasten sicko, I just like having a nice Markdown editor that syncs to my phone). But I want my own copy outside the app, just in case.

I'm not rebuilding their paid sync service (I'm happy to pay for them to store and sync my notes), but I want to guard against:

It turns out it's fairly easy to take offline backups of your Obsidian vaults.

First, you'll need a host for this to run on. I run mine on my home server with direct-attached storage where all my files live (and get encrypted and backed up to the cloud nightly).

Install obsidian-headless, a command-line client for Obsidian Sync (I happen to use mise; you could use npm or Nix or whatever you prefer). Note that this requires an Obsidian Sync account, so it won't work if you're not paying for one of those.

mise use --global node@24 npm:obsidian-headless

You should now have a command called ob; use it to log in and set up the sync. If $VAULTNAME is the name of the vault you're backing up and $BACKUP_DIR is the path to the directory where you want to store your notes locally:

ob login  # this takes your Obsidian account password
ob sync-setup --vault "$VAULTNAME" --path "$BACKUP_DIR"  # this takes your E2EE password
ob sync-config --path "$BACKUP_DIR" --mode pull-only

I set it to pull-only to prevent my backup from interfering with the vault (e.g. a disk fails, the vault looks empty, and syncing deletes the remote).

Finally, set up a recurring job (I used a systemd timer; again, you could use any number of things) to run the sync regularly.

The sync command is:

mise exec -- ob sync --path "$BACKUP_DIR"

Check that it runs automatically and you're set: you now have a backup copy of your notes that gets updated in the background.