# Run your own webdav sync with SabreDAV

**URL:** <https://discourse.devontechnologies.com/t/run-your-own-webdav-sync-with-sabredav/78480>\
**Category:** Tips\
**Tags:** devonthinktogo3, devonthink3, sync\
**Created:** [January 29, 2024, 7:42am UTC](https://discourse.devontechnologies.com/t/run-your-own-webdav-sync-with-sabredav/78480 "2024-01-29T07:42:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cornchip](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/c/e95f7d/32.png) [@cornchip](https://discourse.devontechnologies.com/u/cornchip)\
**Post date:** [January 29, 2024, 7:42am UTC](https://discourse.devontechnologies.com/t/run-your-own-webdav-sync-with-sabredav/78480/1 "2024-01-29T07:42:10Z")

</div>

I thought I’d share how to run a simple PHP webdav server using SabreDAV for syncing DEVONthink databases. Because it’s yours, it’s fast, private and secure. If you already have some PHP hosting, it’s free!

Here’s how to do it.

# The sync app

I’m using [SabreDAV](https://sabre.io/). Here’s the entire app:

 ![Screenshot 2024-01-29 at 12.44.08 AM](https://devontech-discourse.s3.dualstack.us-east-1.amazonaws.com/uploads/original/3X/e/0/e0fb78992bfd89bc190a29b78ba1f29f7a93f583.png)

`data` and `files` are empty directories. Files will hold all your sync data, and `data` is used during sync.

This is a PHP app, so [composer](https://getcomposer.org/doc/00-intro.md) installs packages. The only composer command you need is `composer require sabre/dav`

Here’s index.php. This is the only coding bit. You can just copy this if your app folders look like mine.

```auto
use Sabre\DAV;
use Sabre\DAV\Auth;
use Sabre\DAVACL;

require '../vendor/autoload.php';

$rootDir = new DAV\FS\Directory('../files');

$server = new DAV\Server($rootDir);

$lockBackend = new DAV\Locks\Backend\File('../data/locks');
$lockPlugin = new DAV\Locks\Plugin($lockBackend);
$server->addPlugin($lockPlugin);

$server->addPlugin(new DAV\Browser\Plugin());

$authBackend = new Auth\Backend\File('../.htdigest');
$authBackend->setRealm('SabreDAV');
$authPlugin = new Auth\Plugin($authBackend);
$server->addPlugin($authPlugin);

$server->exec();

```

Here’s the one line .htdigest file. I have all my DT instances using this login, but you can add as many lines as you want. You can generate these lines with an [htdigest generator](https://websistent.com/tools/htdigest-generator-tool/).

```auto
username:SabreDAV:43b3fbe6b608be6e0ef19b3b2ed0fake

```

This protects your files from web access; it’s also your sync credentials.

# Deploying

There are lots of ways to host/deploy this. You just need to run PHP. I’m using [Ploi](https://ploi.io/) to manage an existing Linode server on a new subdomain I made for webdav. You can run this fine on a cheap $5 server, but you’ll need enough storage space for your data. My existing Linode server had about 30GB free, which is plenty. The deploys are just checkout from main, composer install, restart PHP (ploi sets up a default script for this.)

If you can’t use a server manager or composer, you can download and use the source code from [SabreDAV’s releases on GitHub](https://github.com/sabre-io/dav/releases/tag/4.6.0). Then you just deploy by pushing up the whole folder.

If you’re using my folder structure, you want the app’s `public` folder to be root directory of the subdomain so you can visit `webdav.example.com` to make sure webdav is working. You do this because it prevents everything else from being directly browsable.

# Updating

Honestly, you don’t need to update the code unless some awful vulnerability is found, because you won’t be doing further development. Your app and files are completely inaccessible without the password in .htdigest. Security issues from the Sabre projects are rare, anyway.

# DEVONthink setup

In Preferences \> Sync, enable WebDAV. Settings:

- URL: `webdav.example.com`
- User Name and Password are what you used to make your .htdigest file
- Sync Store Name: doesn’t matter
- Encryption: anything you want. Typing something here prevents anyone reading your data on your server. Highly recommended
- Check all the options

---

<div class="post-metadata">

**Author:** ![chrillek](https://discourse.devontechnologies.com/user_avatar/discourse.devontechnologies.com/chrillek/32/29340_2.png) [@chrillek](https://discourse.devontechnologies.com/u/chrillek)\
**Post date:** [January 29, 2024, 7:52am UTC](https://discourse.devontechnologies.com/t/run-your-own-webdav-sync-with-sabredav/78480/2 "2024-01-29T07:52:00Z")

</div>

Why not use the Apache server that comes with macOS?

[https://discussions.apple.com/docs/DOC-250007792](https://discussions.apple.com/docs/DOC-250007792)

No need to install additional packages, no need for clumsy PHP, and it’s a proven implementation.

---

<div class="post-metadata">

**Author:** ![cornchip](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/c/e95f7d/32.png) [@cornchip](https://discourse.devontechnologies.com/u/cornchip)\
**Post date:** [January 29, 2024, 8:06am UTC](https://discourse.devontechnologies.com/t/run-your-own-webdav-sync-with-sabredav/78480/3 "2024-01-29T08:06:56Z")

</div>

This isn’t a guide for people doing that. (I knew I should’ve added disclaimers…) This is for people who want something accessible from the web, don’t want to punch holes in their home network and don’t want to pay for Dropbox or a dedicated sync service, essentially.
