3.6 KiB
3.6 KiB
Obsidian CouchDB Sync - Problem & Solution
What Was Wrong
Your setup had three separate pieces that don't work together:
- ✅ CouchDB - Storing files (WORKING)
- ✅ Obsidian Self-Hosted Sync Plugin - Reading from CouchDB (WORKING)
- ❌ Filesystem Sync - Writing files to disk (MISSING!)
Why Files Weren't Showing
The Obsidian plugin can READ files from CouchDB through its API, but:
- Files weren't being written to the filesystem
- Your
watch_changes.pyonly printed changes, didn't save files - Your
couch_sync.pyCAN sync, but it's not running continuously
The Fix
I created sync_daemon.py which:
- ✅ Connects to CouchDB
- ✅ Does initial full sync (downloads all files)
- ✅ Watches for changes in real-time
- ✅ Writes updated files to disk immediately
- ✅ Reconstructs files from LiveSync's chunk format
- ✅ Skips encrypted files automatically
Quick Start
Step 1: Test Connection
cd obsidian_automator
python3 test_connection.py
This verifies CouchDB is accessible and shows your files.
Step 2: Configure Target Folder
Edit sync_daemon.py, line 16:
TARGET_FOLDER = "/path/to/your/obsidian/vault"
Or keep it syncing to current directory:
TARGET_FOLDER = "/home/diego/Scratchpad/obsidian-magic/obsidian_automator"
Step 3: Run Sync Daemon
python3 sync_daemon.py
You should see:
- Initial sync downloading all files
- Real-time updates as you edit in Obsidian
Step 4 (Optional): Run as Background Service
See SYNC_SETUP.md for systemd service setup.
How It Works
┌─────────────┐
│ Obsidian │ ← Edit files
└──────┬──────┘
│
↓
┌─────────────────┐
│ Self-Hosted │ ← Uploads to CouchDB
│ Sync Plugin │
└──────┬──────────┘
│
↓
┌──────────────┐
│ CouchDB │ ← Stores in chunks
└──────┬───────┘
│
↓ _changes feed
┌──────────────┐
│ sync_daemon │ ← NEW! Watches & writes files
└──────┬───────┘
│
↓
┌──────────────┐
│ Filesystem │ ← Files appear here!
└──────────────┘
Files Changed/Created
- ✨ sync_daemon.py (NEW) - Main sync daemon
- ✨ test_connection.py (NEW) - Connection tester
- ✨ SYNC_SETUP.md (NEW) - Detailed setup guide
- ✨ FIX_SUMMARY.md (NEW) - This file
Existing files (not modified):
couch_sync.py- Still used by web UIcouch_manager.py- Still used for operationswatch_changes.py- Keep for debugging
Next Steps
- Run
test_connection.pyto verify setup - Edit
TARGET_FOLDERinsync_daemon.py - Run
sync_daemon.py - Check that files appear in target folder
- Make changes in Obsidian and watch them sync
- (Optional) Set up as systemd service for auto-start
Troubleshooting
No files appearing?
- Check
TARGET_FOLDERpath is correct and writable - Verify CouchDB connection with
test_connection.py - Check daemon output for errors
Connection refused?
- Verify CouchDB is running:
curl http://100.100.112.48:5984/ - Check credentials in
sync_daemon.py - Check firewall/network settings
Files are encrypted?
- Daemon skips encrypted files by default
- To sync encrypted files, need to add passphrase decryption
Need help? Check SYNC_SETUP.md for more details!