An incredibly imperfect implementation of a backup tool for my Obsidian dotfiles. It helps me:
- Hardlink plugin customizations (data.json) in any easy-to-backup way
- See where I've drifted between environments by comparing directories
Oh, absolutely. I looked at the git plugin but I didn't want to figure out how to make it work across separate Obsidian environments. I can also think of at least two better implementations:
- An Obsidian plugin that handles this all
- Building this into a compiled utility with a less clumsy argument structure
usage: obsidian_plugin_backup.py [-h] [-c] [-l] [-a] -s SOURCE -d DESTINATION
optional arguments:
-h, --help show this help message and exit
-c, --compare Compare directories
-l, --link Create hardlinks
-a, --archive Archive destination directory
-s SOURCE, --source SOURCE Source directory
-d DESTINATION, --destination DESTINATION Destination directory
- Clone https://github.com/mbbroberg/obsidian-dotfile-backup
- Run it once to hard-link the dotfile folder to your home folder
$ python ./obsidian_plugin_backup.py -l -s "TODO_YOURVAULT/.obsidian/" -d "~/obsidian"
- Clone https://github.com/mbbroberg/obsidian
- Either manually run
~/obsidian/auto-backup-obsidian.sh
or setup a service to run it periodically
Replace TODO_YOURUSERNAME
with your username in the plist file then run:
$ cp com.user.obsidian.backup.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/com.user.obsidian.backup.plist
Verify it's enabled in System Preferences > Users & Groups > Login Items
1: Double check the existance of log files, hard links, and permissions. You may have to touch
the log files to create them or chmod +x
the script.
2: Increase the frequency of the backup by replacing 1800
with 60
in ~/obsidian/auto-backup-obsidian.sh
Reload:
launchctl unload -w ~/Library/LaunchAgents/com.user.obsidian.backup.plist
launchctl load -w ~/Library/LaunchAgents/com.user.obsidian.backup.plist
Then watch the logs:
tail -f ~/obsidian/backup-error.log ~/obsidian/backup-output.log
I only had the patience and time to put this together because I used GitHub Copilot at first and Cody with Claude at other times. I want to thank everyone whose contributed code helped me navigate this problem.