Syncing Obsidan to iOS using Dropbox

2022-01-18

It was said to be impossible, but I finally have obsidian on my iPhone fully in sync with my obsidian vault in dropbox on my windows computer. No need to pay for Obsidian's sync, or to consider using shudder iCloud Drive as the home of your vault

Well, not techincally... You do need to install iCloud Drive for Windows. The plan is to duplicate the vault and sync it on the computer over iCloud. iCloud will only hold an up to date copy of the vault. The true copy will live in Dropbox, as it should. Now windows has a built way to mirror this type of duplicating a folder multiple places on disk. Linux uses know this as a hardlink, but it goes by junction in the world of windows. Surely we can just make one and this will be super easy.

The First Attempt

Making a junction is simple, just pop open a command prompt window and type

mklink /j ~/iCloudDrive/Obsidian/Vault ~\Dropbox\Vault\

Perfect. The files are a perfect copy in iCloud. And while iCloud drive shows a syncing icon, it will never go away. Okay...maybe we can do it the reverse way?

Nope. Putting the junction in Drobox with the original in iCloud drive will show a big X next to the file in dropbox.

Unison to the Rescue

Luckily, there is a utility made for just this purpose. Unison is a CLI app that will sync two folders, and it is easy to install with scoop.

scoop install unison

Now we can delete our copy of the vault in iCloud and try running

unison ~\Dropbox\Vault ~\iCloudDrive\iCloud~md~obsidian\Vault\ -batch

Perfect. The files are synced up. Adding -batch removes all y/n prompts. Which is handy, because now we need to run this thing all the time

Task scheduler - the Vista of Cron Jobs

To run a repetative task, like cron would on linux, windows has the Task Scheduler, a nightmare of a program. It only allows arbitrary times and triggers, has a horrid UI, and is a linux dev's worst nightmare, but it works.

Open her up and create a new task:

We can choose to start it both once and hour and on login, but we can even do better. Below that, select repeat every 5 minutes. That should be good enough. Put our unison command in a .bat file and we are up and running

Except the unison command runs in a new window every time, which steals focus and is ugly. Upon searching stack overflow, we can find another windowsy workaround.

/c start "Sync" /min "C:\Users\brian\Dropbox\Scripts\sync-obsidian.bat" ^& exit

Except that doesnt work... another? Okay... Put this

CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 2, False

In a .vbs file, then run this as our task.

"c:\path\run_minimized.vbs" "c:\path\unison_script.bat"

That works!

And there we are! Obsidian vault in Dropbox, syncing to our iOS devices. Happy note taking.

← Back