Handshake between docker-duplicati and host

so just fyi, after a lot of tinkering, this is the solution I have came to. It involves homeassistant (which I have anyhow) and installing webhook on the file server (=docker host)

Every day on 0:00 the homeassistant server triggers an automation:
switch on backup drive (via switchable power socket)
trigger webhook script on file server that:
 - mounts the backup drive
 - waits 10s
 - starts duplicati container

duplicati has all backups scheduled on 0:00 so they should run immediately
On 0:05 there is a "dummy backup" job scheduled which is only needed for triggering a script 
run-script-after that triggers a shutdown webhook on homeassistant (just a curl command which is 
luckily available in the docker container)
(relying the dummy backup job always runs last, even if the other jobs are not finished on 0:05)

The shutdown automation on homeassistant will:
- trigger a webhook on fileserver which will
  - stop the duplicati container
  - wait 10 seconds
  - unmount the backup drive
- wait 10 seconds
- switch off the backup drive

Since there is a whole chain of events needed for this to work, add some failsafe (like adding a timeout that shuts down the whole stuff after 3 hours even without receiving “backup finshed” notification and you are good to go.

Of course, if you don’t need to power on/off your drive, you can skip the home automation server and directly trigger webhooks on the duplicati host for any other handshake.

1 Like