linde: fix rdiff-backup error handling the `remove increments` subcommand often emits warnings and returns a non-zero error code, which is ignored by the `-` prefix of the command (see systemd.service(5))
Alan Pearce alan@alanpearce.eu
Sun, 05 Jan 2025 12:05:55 +0100
1 files changed, 10 insertions(+), 13 deletions(-)
jump to
M system/linde.nix → system/linde.nix
@@ -455,31 +455,28 @@ systemd.services.backup-gitolite = { startAt = "daily"; path = with pkgs; [ - rdiff-backup openssh ]; - script = '' - rdiff-backup --api-version 201 backup ${config.services.gitolite.dataDir} ${hostname}@nano.${ts-domain}::gitolite - rdiff-backup --api-version 201 remove increments --older-than 3M ${hostname}@nano.${ts-domain}::gitolite - ''; - serviceConfig.Type = "oneshot"; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${lib.getExe pkgs.rdiff-backup} --api-version 201 backup ${config.services.gitolite.dataDir} ${hostname}@nano.${ts-domain}::gitolite"; + ExecStartPost = "-${lib.getExe pkgs.rdiff-backup} --api-version 201 remove increments --older-than 3M ${hostname}@nano.${ts-domain}::gitolite"; + }; }; systemd.services.backup-paperless = { startAt = "daily"; path = with pkgs; [ - sudo - rdiff-backup openssh ]; - script = '' - systemd-run --machine=papers sudo -u paperless ./paperless-manage document_exporter --delete --use-filename-format --no-archive --no-thumbnail --no-progress-bar ./export - rdiff-backup --api-version 201 backup /srv/paperless/export ${hostname}@nano.${ts-domain}::paperless - rdiff-backup --api-version 201 remove increments --older-than 3M ${hostname}@nano.${ts-domain}::paperless - ''; serviceConfig = { Type = "oneshot"; WorkingDirectory = config.services.paperless.dataDir; + ExecStart = [ + "systemd-run --machine=papers sudo -u paperless ./paperless-manage document_exporter --delete --use-filename-format --no-archive --no-thumbnail --no-progress-bar ./export " + "${lib.getExe pkgs.rdiff-backup} --api-version 201 backup /srv/paperless/export ${hostname}@nano.${ts-domain}::paperless" + ]; + ExecStartPost = "-${lib.getExe pkgs.rdiff-backup} --api-version 201 remove increments --older-than 3M ${hostname}@nano.${ts-domain}::paperless"; }; };