From 13d40341a058d750722b545490c7d690fa0a3640 Mon Sep 17 00:00:00 2001 From: Johanna Dorothea Reichmann Date: Sun, 14 Apr 2024 15:14:02 +0200 Subject: [PATCH] fix(restic): change systemd service type to simple, remove wanted-by, allow post-start hooks The old service type oneshot combined with a wanted-by of multi-user.target can lead to an infite recursion which systemd does not warn about, causing a service that never activates. --- roles/restic/templates/restic.service.j2 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/restic/templates/restic.service.j2 b/roles/restic/templates/restic.service.j2 index 11e89d5..52449c4 100644 --- a/roles/restic/templates/restic.service.j2 +++ b/roles/restic/templates/restic.service.j2 @@ -2,7 +2,7 @@ Description={{ restic_job_description }} [Service] -Type=oneshot +Type=simple User={{ restic_user }} WorkingDirectory={{ restic_systemd_working_directory }} SyslogIdentifier={{ restic_systemd_syslog_identifier }} @@ -22,7 +22,7 @@ ExecStart=/usr/bin/restic --verbose backup {{ restic_backup_paths | join(' ') }} {% endif %} ExecStartPost=/usr/bin/restic forget --prune --keep-within={{ restic_policy.keep_within }} --keep-hourly={{ restic_policy.hourly }} --keep-daily={{ restic_policy.daily }} --keep-weekly={{ restic_policy.weekly }} --keep-monthly={{ restic_policy.monthly }} ExecStartPost=-/usr/bin/restic snapshots +{% if restic_backup_post_hook %} +ExecStartPost=-{{ restic_backup_post_hook }} +{% endif %} ExecStartPost=/usr/bin/restic check - -[Install] -WantedBy=multi-user.target