Backup at shutdown


Banging my head against the wall. Why doesn’t this Systemd service run?
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/
Description=Backup with restic before shutdown

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


It runs if I start it manually: systemctl --user start restic-backup.service
It seems to enable fine: systemctl --user enable restic-backup.service
Created symlink /home/lance/.config/systemd/user/ /home/lance/.config/systemd/user/restic-backup.service. Created symlink /home/lance/.config/systemd/user/ /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?


Yep. You can’t have dependencies on system level services in a user service file. Create/enable it as a system service but with the User= directive (if required).