SSH sync with Ipad

Hi I just wanted to share a method to sync for free (manually) with an ssh server and IOS. Most of this is thanks to the efforts of all those figuring out how to sync with git. The benefit of this is there are no third-party servers and its fully encrypted between your iPad and server.

My current platforms:

  • Linux desktop
  • Ipad
  • Android phone
  • Linux NAS

I use syncthing to sync across all the Linux environments.

My NAS is the central point of truth and I run an SSH server on that to sync with iPad.

Using iSH I am then able to use rsync back and forth to sync.

I wont go through setting up the server side of things, just how to use iSH and setup commands to quick sync. I only just set this up so please share improvements.

Firstly create a dummy vault in Obsidian on the iPad with the same name as your main vault. We will fill it later with rsync

Install iSH from the App Store

Open iSH and install rsync in iSH

apk add rsync

Make a dir to mount the Obsidian folder stored on your IOS device

mkdir Obsidian

Now mount the actual Obsidian folder inside the Obsidian folder we created in iSH

mount -t ios . Obsidian

A file browser will appear. Select /On My Ipad/Obsidian

You should now have your local Obsidian files mounted within iSH. Check in iSH with

cd Obsidian
ls -la

You should see something like

drwxr-xr-x 3 501 501 96 Aug 24 05:44 .
drwx------ 5 root root 160 Aug 26 08:10 …
drwxr-xr-x 13 501 501 416 Aug 26 08:23 [vault name]

We are now ready to sync with your ssh server. You can tweak the rsync command to suit your needs, i use the —delete and -rtP flags (recursive, preserve time stamps, show progress). IOS wont preserve permissions so the traditional -avz throws a heap of errors. Also run it with the —dry-run command first time to check everything.

rsync -rtP user@host:RemoteFolder/Obsidian/ ~/Obsidian --delete --dry-run

Whether there is a trailing / or not is important with rsync. In this instance it will take all the sub folders from the remote Obsidian folder and place them within the local Obsidian folder. If you don’t have the trailing / it will create Obsidian/Obsidian/[vaultname] on your iOS device.

If the dry run looks ok and it is transferring to the correct folders, run again without —dry-run. This will sync all settings and plugins and all your vaults.

I have some plugins and settings that don’t work as well on ipad as on the desktop. So after the initial sync I use the —exclude .obsidian flag to ignore the hidden obsidian folder containing settings etc. This way i get all my plugins and settings first up, I can make the necessary changes in the ipad version of Obsidian to suit my needs. From then on it just syncs the markdown files and attachments in my vaults.

Now this is done we can setup the commands to manually sync back and forth. To sync to the ipad add an alias in iSH

alias pull=‘rsync -rtP user@host:Documents/Obsidian/ ~/Obsidian --delete --exclude .obsidian’

To push changes to the server

alias push=‘rsync -rtP ~/Obsidian/ user@host:Documents/Obsidian --delete --exclude .obsidian’

Now just type pull and push in iSH to sync down and up.

You can setup authorised_keys in the .ssh folder on your linux server so you don’t have to type your ssh password every time.

rsync is great because for large vaults it will only xfer new and changed files.

Hope this is helpful. I am sure there are better ways to do this or improvements please post here.

Also this isn’t a work around because I don’t want to pay for sync. Obsidian is the best piece of software I have come across in the last 10 years.
It has revolutionised the way I take notes and I have been dreaming of something like this for years. It is exactly how I have always believed folder structures, notes etc should work. I would love to support development however I do prefer to be totally in control of my data and I am not a huge fan of subscription models. If a self hosted sync option for a one off payment was available I would buy that in a heatbeat

5 Likes

That is very interesting, thanks for the writeup. However, in my case, rsync doesn’t work. It just hangs while transferring the first file (for the initial pull).

The same rsync/pull command into a plain directory inside the iSH sandbox works, but as soon as I mount the ios Obsidian directory and try to rsync into that directory, it hangs.

I tried the --whole-file/-W flags, no change.

Any ideas?

I found the solution to my problem over here:

mount -t ios-unsafe . obsidian

But - with constraints after an iSH restart

Same problem , thanks for your solution.

1 Like