Obsidian WebDAV sync

Getting started

This guide assumes you've already installed the plugin. If you haven't, see installing the plugin

  1. Getting started
    1. Words of warning
    2. Setting up a WebDAV server
      1. Setup of known WebDAV servers
    3. Setting up the plugin
    4. Your first sync
    5. Adding devices
    6. Day-to-day syncing

Caution

Do not use 0.4.0 or earlier. These versions use an old plugin ID that was yoinked by another plugin by the same name submitted 6 months after this plugin. See #25 (GitHub) or the changelog for more information, and migration steps if you currently use 0.4.0 or older.

Words of warning

The plugin is designed to minimise risk during normal operation. No automatic sync means that every device you have acts as a separate backup of the vault, so even if something goes wrong, you have a path to recovery.

However, during setup, there are a few failure points that the plugin hasn't been configured to protect you from. Worst-case, you wipe your vault.

The plan eventually is to outright (and without the ability to bypass) block the ability to do a full wipe on pull, but this is not yet implemented. During plugin setup, you _need_ to read the docs before you do anything, as going for "download" without first pushing your vault will wipe your vault locally.

For good measure, I suggest taking a backup before first-time use. If all you have is one copy of the vault, user error can and will destroy it irrecoverably. Take your time and use common sense while setting up the plugin.

Setting up a WebDAV server

If you don't have access to one already, you'll need a WebDAV server before doing this. Some setup examples are shown in webdav-servers/.

Due to how obsidian works, CORS is in play. CORS is just as much of a pain in the ass here as anywhere else. For the plugin to work if your WebDAV server has CORS, you need to do one of two things:

  1. Disable CORS; this is, by far, the easiest option, but obviously has security tradeoffs.

  2. Set up CORS to allow app://obsidian.md and a whole bunch of other stuff that I cannot easily summarise. Even that documentation does not include an exhaustive list.

Other requirements:

Setup of known WebDAV servers

Other WebDAV servers are likely supported with minimal or no special setup, but I do not attempt to verify these. If you manage to verify another server, please consider opening a PR with setup instructions (if applicable; just adding a server to the list as working out of the box is also fine).

Setting up the plugin

Before you can do any syncing, go to the WebDAV sync settings. Here, you'll need to add the following settings:

Your first sync

The first push is relatively straight-forward. In the ribbon, a sync button is added by default. When clicked, you'll get a modal asking whether you want to push or pull. You should use this for your first sync, even if you don't want to keep the button around. It gives you access to more options than the commands do, so you can see more clearly what's going to happen before you do it.

Caution

It's vitally important that you do not press "Download" at this point. If you do not have a backup, and you did not initialise your vault in the cloud manually, your vault is gone. No security measures have been implemented yet to prevent this, so common sense is required. User error can and will fuck you up at this point.

In this menu, you'll also find a "dry run" toggle. As the toggle explains, it results in the plugin telling you what changes it would've made, but without actually performing them. This is also useful if you're pulling, but not sure what changes would've been made.

Once you click "upload", your entire vault will be synced to the remote WebDAV share. Once completed, you can verify that it's completed by trying a second upload. If it's complete, you'll get a message saying no changes were made.

Note

This only works reliably if your WebDAV server supports the X-OC-MTime header. Without it, if you use dry run, you'll see that all the files you just uploaded count as modified in the remote.

Adding devices

One major downside with this plugin is that adding extra devices requires having at least partial vault access. Though it's possible to create a new vault, I strongly suggest you copy over your entire vault as a first sync. Once the plugin is set up, this includes everything you need to sync.

Note

As of 0.2.0, SecretStorage is used, which means you'll need to relink the password after copying. Make sure you use the same key name on both devices. The key name is synced between devices via the settings file, so a conflict between devices on the key name will cause the password to keep delinking on sync. This is a weakness in how obsidian set up secret linkage.

Day-to-day syncing

There's both a ribbon entry and currently two actions that can be used to actually do the syncing. There will be more actions in the future that cover everything you'd do with the ribbon entry, but this plugin is still in an early development phase.

The sync modal (opened through the ribbon) offers all the available per-sync options. At the time of writing, these include:

Aside the modal, raw upload and download actions exist, accessible via Ctrl-P (search "WebDAV:" to see all the available actions). Unless otherwise specified, the actions use all default settings, which amy be undesirable. If you need more control, use the modal.