Why doesn't this Systemd service run?

2

I'm trying to run a user service, to backup my documents, before the desktop system shuts down every night.

# Needs to be placed in ~/.config/systemd/user/
[Unit]
Description=Backup with restic before shutdown
Before=poweroff.target halt.target
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/restic backup --verbose --one-file-system --tag systemd.shutdown $BACKUP_EXCLUDES $BACKUP_PATHS
ExecStartPost=/usr/bin/restic forget --verbose --tag systemd.shutdown --group-by paths,tags --keep-daily $RETENTION_DAYS --keep-weekly $RETENTION_WEEKS --keep-monthly $RETENTION_MONTHS --keep-yearly $RETENTION_YEARS
EnvironmentFile=%h/.config/restic-backup.conf
RemainAfterExit=yes

[Install]
WantedBy=poweroff.target halt.target 

It runs if I start it manually: systemctl --user start restic-backup.service

It seems to enable fine: systemctl --user enable restic-backup.service Returns:

Created symlink /home/lance/.config/systemd/user/poweroff.target.wants/restic-backup.service → /home/lance/.config/systemd/user/restic-backup.service.
Created symlink /home/lance/.config/systemd/user/halt.target.wants/restic-backup.service → /home/lance/.config/systemd/user/restic-backup.service.

...but when I go to the desktop menu & shutdown, the script does not run, the computer just shuts down.

Anyone see what I'm missing?

Lance Haverkamp

Posted 2019-04-28T17:42:13.420

Reputation: 21

You can add debug to the kernel command line to enable systemd debugging (many verbose messages written). – U. Windl – 2019-04-29T08:10:10.853

No answers