[Unit] Description=backup of docker-compose service %i with borgmatic Wants=network-online.target After=network-online.target ConditionACPower=true [Service] ExecStartPre=systemctl stop docker-compose@%i.service Type=oneshot # Lower CPU and I/O priority. Nice=19 CPUSchedulingPolicy=batch IOSchedulingClass=best-effort IOSchedulingPriority=7 IOWeight=100 Restart=no # Prevent rate limiting of borgmatic log events. If you are using an older version of systemd that # doesn't support this (pre-240 or so), you may have to remove this option. LogRateLimitIntervalSec=0 # Delay start to prevent backups running during boot. Note that systemd-inhibit requires dbus and # dbus-user-session to be installed. ExecStart=systemd-inhibit --who="borgmatic-%i" --why="Prevent interrupting backup of %I" /usr/local/bin/borgmatic -c /etc/borgmatic/%i.yaml --syslog-verbosity 1 ExecStopPost=/usr/local/bin/restart-compose-after-backup.sh %i