Obsidian-git-backup-docker: automatic git versioned backup with obsidian-headless

tl;dr: A Docker container that automatically backs up your Obsidian vault to git. It uses obsidian-headless (official Obsidian sync client) to receive vault changes, watches for file changes with inotify (no polling), then commits and pushes to a git remote. Runs 24/7 on a server or NAS — no plugins needed in Obsidian, works regardless of which device you’re editing on.


Hello Obsidian community!

So I’ve been using Obsidian for a while and I love it. But I also love git. I want to combine the two, to get versioned backup. However the current options don’t really fit my case. What I want is a continous process running on my server, which sync using the normal (well-functioning) Obsidian Sync. Which automatically reacts to file changes and commits/pushes it to git.

I don’t want to manually juggle the git repo, I just want it to auto-commit.

Couple of standout features:

  1. A debounce timer (that you can customize the length of). This way you can get the whole meeting notes in one commit, just set it to 10 minutes or something!
  2. Tons of screenshots and images in your repo? No problem! This image puts it all in Git LFS!
  3. Plugin-XML file for Unraid. Super easy to deploy! (not merged to the central Unraid repo yet since we’re so early)

Built with some agentic help of course, but works quite well.

https://github.com/benedicteb/obsidian-git-backup-docker

Is this something you can see yourself using? Any feedback? Suggestions for improvements and so on? Feel free to try it out and let me know!

I’m imagining an `OLLAMA_HOST` option where it auto-generates actually relevant commit messages could be a nice next step.

1 Like

I’m currently using the Git plugin to backup to Github and it generally works well. Could you explain the differences between your approach and the Git plugin, what are the pros/cons of each and why one might want to choose one over the other?

Hey there! :blush:

The main difference is that this image is meant to run standalone on a server of some kind. That way you’re not dependant upon your laptop (with obsidian-repo + git-plugin) being open at all.

To me the git-plugin provides a complete git integration to your Obsidian repo. With diff-view, manual committing and everything.

This image is not that, this is just a passive listener which auto-commits. (And is not installed in your repo as a plugin at all)

Some nice pros for me at least are that:

  1. I can use my phone only for Obsidian and still have auto-backup
  2. I don’t have to mix git and obsidian (which is a big thing for me, when I’m in Obsidian I wanna write, not do git-stuff)
  3. There’s no potential for git conflicts (not sure how the git-plugin handles multiple devices but maybe this isn’t an issue at all)

So tl;dr I guess is: git-plugin goes in your repo and gives more features. While this image is completely passive, but can run 24/7 without any actual device.

It does eat up one of your Sync slots though. Worth noting.

1 Like

Thanks for putting this together @benedicteb , it’s exactly what I was looking for, in fact Claude pointed me to this forum post, i’ll be installing your docker image.

1 Like

I set it up and it’s working beautifully ! Thank you so much for taking the time to put together this very polished project @benedicteb ! I’ve also got my vault bind-mounted and plan on doing more AI stuff later. Just checking, is the sync two way or one way ? I wish for one-way, modifying files on the bind mount shouldn’t affect my obsidian notes.

Hey! I’m happy to hear that! You’re very welcome! :blush:

I looked into the “sync-direction”! Turns out that `obsidian-headless` actually has a parameter for this. So I spun up a quick PR so you can customize it in the image :blush: PR is here:

I’d merge it right away but would be nice to test that it works first, and I don’t have time right now. Maybe you could help me out? :blush:

Just clone the image with this tag:

docker pull benedicteb/obsidian-git-backup:latest_feat-sync-mode-env-var

And you can set the sync-direction with `OBSIDIAN_GIT_SYNC_MODE=pull-only` (valid values bidirectional (default), pull-only, mirror-remote) for example. There are full testing instructions in the PR.

Let me know if it covers your use case!