log / setting up obsidian sync with rclone on arch linux

The Problem

I wanted to sync my Obsidian vault between my Arch Linux machine and Google Drive. My initial thought was to mount Google Drive at boot using google-drive-ocamlfuse and point Obsidian directly to the mounted folder. Simple, right? Well, not exactly.

Why Not Mount Google Drive for Obsidian?

After some research, I realized that mounting Google Drive with FUSE filesystems like google-drive-ocamlfuse isn’t optimal for Obsidian. Here’s why:

Performance Issues:

  • Every file operation requires a network request to Google Drive
  • Obsidian constantly scans your vault for indexing
  • Opening notes feels sluggish due to network latency
  • Search and graph view become painfully slow

No Offline Access:

  • Can’t work on notes without internet
  • Connection drops mean you lose access to your vault

File Watching Problems:

  • Obsidian’s live preview might not work properly
  • FUSE filesystem + file watchers = potential reliability issues

The better approach is to keep local copies and sync them periodically. This gives you fast local access while maintaining backup in the cloud.

The Solution: Rclone Bisync

Rclone’s bisync command provides true bidirectional synchronization. Changes on either side (local or Google Drive) get synced to the other. Combined with systemd timers, we can automate this process to run every few minutes.

Setting Up Rclone

First, install and configure rclone:

# Install rclone
sudo pacman -S rclone

# Configure Google Drive
rclone config

During configuration:

  1. Choose n for new remote
  2. Name it (I used GDrive-obsidian.purnasatria)
  3. Select Google Drive as the storage type
  4. Follow the authentication flow

Verify your setup:

# List your Google Drive folders
rclone lsd GDrive-obsidian.purnasatria:

# Check if your Obsidian folder exists
rclone lsd GDrive-obsidian.purnasatria:obsidian-note-v5

Initial Sync

Before automating, we need to perform an initial resync:

rclone bisync GDrive-obsidian.purnasatria:obsidian-note-v5 \
  ~/Workspace/note/obsidian-note-v5 \
  --resync --verbose

This creates tracking files that bisync uses to detect changes. You should see output ending with:

INFO : Bisync successful
Transferred: XX KiB / XX KiB, 100%

Automating with Systemd

Create the systemd service file:

nano ~/.config/systemd/user/obsidian-sync.service

Add this content:

[Unit]
Description=Sync Obsidian Vault to Google Drive
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/rclone bisync GDrive-obsidian.purnasatria:obsidian-note-v5 %h/Workspace/note/obsidian-note-v5 --verbose --create-empty-src-dirs
Restart=on-failure
RestartSec=30

[Install]
WantedBy=default.target

Key points about the service:

  • Type=oneshot means it runs once and exits (not a continuous daemon)
  • %h is systemd’s variable for your home directory
  • --create-empty-src-dirs ensures empty folders sync on both sides (useful for Obsidian’s folder structure)
  • Restart=on-failure with RestartSec=30 provides resilience if sync fails temporarily

Create the timer file:

nano ~/.config/systemd/user/obsidian-sync.timer

Add this content:

[Unit]
Description=Sync Obsidian Vault every 5 minutes
Requires=obsidian-sync.service

[Timer]
OnBootSec=1min
OnUnitActiveSec=5min
AccuracySec=1min

[Install]
WantedBy=timers.target

Timer explanation:

  • OnBootSec=1min triggers first sync 1 minute after boot (gives network time to stabilize)
  • OnUnitActiveSec=5min runs sync every 5 minutes after last completion
  • AccuracySec=1min allows systemd to batch timer activations for efficiency

Enable and start the timer:

# Reload systemd
systemctl --user daemon-reload

# Enable timer to start on boot
systemctl --user enable obsidian-sync.timer

# Start timer now
systemctl --user start obsidian-sync.timer

# Check status
systemctl --user status obsidian-sync.timer

# See when next sync will run
systemctl --user list-timers

Troubleshooting

Error: Cannot Find Prior Listings

If you see this error:

ERROR : Bisync critical error: cannot find prior Path1 or Path2 listings
ERROR : Bisync aborted. Must run --resync to recover.

Solution: Stop the service and run resync manually:

# Stop the service
systemctl --user stop obsidian-sync.timer
systemctl --user stop obsidian-sync.service

# Clear cache and resync
rm -rf ~/.cache/rclone/bisync/*
rclone bisync GDrive-obsidian.purnasatria:obsidian-note-v5 \
  ~/Workspace/note/obsidian-note-v5 \
  --resync --verbose

# Restart timer
systemctl --user start obsidian-sync.timer

Error: Check Access Failed

If you see:

ERROR : Access test failed: Path1 count 0, Path2 count 0 - RCLONE_TEST
ERROR : Bisync critical error: check file check failed

The --check-access flag requires a RCLONE_TEST file in both locations. Since we don’t need this extra safety check, just remove the flag:

nano ~/.config/systemd/user/obsidian-sync.service

Remove --check-access from the ExecStart line, then:

systemctl --user daemon-reload
systemctl --user restart obsidian-sync.timer

Useful Commands

# View sync logs in real-time
journalctl --user -u obsidian-sync.service -f

# Manually trigger a sync
systemctl --user start obsidian-sync.service

# Stop automatic sync
systemctl --user stop obsidian-sync.timer

# Check timer status
systemctl --user is-active obsidian-sync.timer

# List all sync-related files
ls ~/.cache/rclone/bisync/

How It Works

Once set up, here’s what happens:

  1. At boot: Timer starts and waits 1 minute for network stability
  2. First sync: Compares Google Drive folder with local folder and syncs changes bidirectionally
  3. Recurring syncs: Every 5 minutes, the timer triggers the service again
  4. Sync process:
    • Lists files in both locations
    • Compares with previous state (stored in ~/.cache/rclone/bisync/)
    • Transfers only changed files
    • Updates tracking files for next sync

Alternative Sync Solutions

Google Drive Desktop

If you’re using macOS alongside Arch Linux, Google Drive Desktop works fine with Obsidian as long as you:

  • Edit on one device at a time
  • Wait for sync to complete before switching devices
  • Close Obsidian before switching devices

The downside is potential conflict files when both sides change between syncs.

Syncthing

For real-time synchronization, Syncthing is excellent for Obsidian:

# Install on Arch
sudo pacman -S syncthing

# Enable and start
systemctl --user enable --now syncthing

Access the web UI at http://localhost:8384

Advantages:

  • Real-time sync (changes appear in seconds)
  • Better conflict handling
  • P2P sync without cloud middleman
  • Free and open source

My recommendation: Use Syncthing for fast device-to-device sync, and keep rclone bisync running hourly or daily as a backup to Google Drive.

Conclusion

Setting up rclone bisync with systemd provides a reliable, automated way to keep your Obsidian vault synchronized with Google Drive. The 5-minute sync interval strikes a good balance between freshness and system resource usage. While it’s not real-time like Google Drive Desktop or Syncthing, it’s more than adequate for typical Obsidian usage where you’re editing on one device at a time.

The setup gives you:

  • Fast local access to all your notes
  • Offline access when needed
  • Automatic background synchronization
  • Free cloud backup using Google Drive storage
  • Complete control over the sync process

For my use case with an Arch Linux laptop, this solution works perfectly. The systemd integration means I don’t have to think about syncing—it just happens automatically in the background.

Written on 2024-12-24 00:00:00 +0700 Edited on 2024-12-24 00:00:00 +0700