Linux: autostart

I had to reinstall my OS, but I can’t remember how to autostart duplicacy at boot. I don’t remember ever having to write a systemd script…but it’s been a long time.

I’m running the web-ui, in KDE, on OpenSUSE.

This is my service unit:

15:26:50 ~ $ cat /etc/systemd/system/duplicacy.service 
[Unit]
Description=Duplicacy backup

Wants=network.target
After=syslog.target network-online.target

[Service]
Type=simple
EnvironmentFile=/etc/duplicacy_web.env
Environment="HOME=/root"
ExecStart=/usr/local/bin/duplicacy_web -background -no-tray-icon
Restart=on-failure
RestartSec=10
KillMode=process
 
[Install]
WantedBy=multi-user.target

And this is what’s in the duplicacy_web.env file:

15:28:29 ~ $ sudo cat /etc/duplicacy_web.env
# Where to create the .duplicacy-web folder
HOME=/root
# Encryption password; without this jobs won't run until you manually log on.
# SECURITY RISK! Keep this file tightly privileged.
DWE_PASSWORD="definitelynotmyrealpasswordhere"

Yes, I’m aware HOME= is defined both in the service unit and in the env file. There’s a reason for that, but I don’t remember it :stuck_out_tongue:
It may be a reason you’ll never run into, though, so feel free to experiment with one or the other.

Something I have noticed is that dbus and keyring processes have a tendency to stick around in the cgroup. If you rarely shut down your computer you may want to occasionally stop duplicacy and then kill it (systemctl stop duplicacy && systemctl kill duplicacy && systemctl start duplicacy) to clear those out. Not that I have noticed any particular downsides, mind, I’m just a stickler for cleaning up :slight_smile:
Maybe I should tweak KillMode= sometime, never played with it.

And hours after I say that, one of my Duplicacies seems to have crashed; I haven’t investigated the actual cause yet, but…

root@zomboni:~# systemctl status duplicacy | grep -c dbus
306

306 dbus-daemons, and zero duplicacy_web processes… so that might well be related :slight_smile: