Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restic: Service assumes --files-from is in use. #264696

Closed
hughobrien opened this issue Nov 1, 2023 · 4 comments · Fixed by #264882
Closed

Restic: Service assumes --files-from is in use. #264696

hughobrien opened this issue Nov 1, 2023 · 4 comments · Fixed by #264882
Labels
0.kind: bug Something is broken

Comments

@hughobrien
Copy link
Contributor

hughobrien commented Nov 1, 2023

Describe the bug

Recent changes to the nixos/modules/services/backup/restic.nix assume the presence of the --files-from list even when it is not in use (it defaults to null). This prevents the service from running.

Problem line:

ExecStart = (optionals doBackup [ "${resticCmd} backup ${concatStringsSep " " (backup.extraBackupArgs ++ excludeFlags)} --files-from=${filesFromTmpFile}" ])

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create a backup service without the 'dynamicFilesFrom' option
  2. Observe that --files-from= is included in the service's ExecStart
  3. Observe service failing due to no such file or directory error

Expected behavior

Argument should not be passed if dynamicFilesFrom is not in use

Screenshots

Additional context

Notify maintainers

@i077 @mbrgm @dotlambda

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.5.9, NixOS, 23.11 (Tapir), 23.11.20231029.0cbe9f6`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.17.1`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
@hughobrien hughobrien added the 0.kind: bug Something is broken label Nov 1, 2023
@hughobrien
Copy link
Contributor Author

cc @robryk

@robryk
Copy link
Contributor

robryk commented Nov 1, 2023 via email

@hughobrien
Copy link
Contributor Author

The problematic section is unconditional so I do not believe the config matters. Nevertheless

    restic.backups = {
      "${hostName}" = {
        paths = [ "/home/${user}" "/persist" ];
        repository = "sftp:storage:restic-${hostName}";
        passwordFile = "/persist/restic/storage-pass";
        user = "root";
        extraBackupArgs = [ "--verbose" "--compression=max" "--exclude-file=/persist/restic/storage-exclude" ];
        extraOptions = [ "sftp.command='ssh storage -F /persist/restic/config -s sftp'" ];
        pruneOpts = [ "--keep-daily 14" "--keep-weekly 12" "--keep-monthly 18" "--keep-yearly 100" ];
        checkOpts = [ "--with-cache" ];
        timerConfig = {
          OnCalendar = "05:00";
          RandomizedDelaySec = "30m";
        };
      };

× restic-backups-fw.service
     Loaded: loaded (/etc/systemd/system/restic-backups-fw.service; linked; preset: enabled)
     Active: failed (Result: exit-code) since Wed 2023-11-01 05:28:29 EDT; 4h 38min ago
TriggeredBy: ● restic-backups-fw.timer
    Process: 136119 ExecStart=/nix/store/wigwy3s2kssq28z2nxjxyqc2yqd6ckvq-restic-0.16.1/bin/restic -o sftp.command=ssh storage -F /persist/restic/config -s sftp backup --verbose --compression=max --exclude-file=/persist/restic/storage-exclude --files-from=/run/restic-backups-fw/includes (code=exited, status=1/FAILURE)
   Main PID: 136119 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 10ms

Nov 01 05:28:29 fw systemd[1]: Starting restic-backups-fw.service...
Nov 01 05:28:29 fw restic[136119]: open /run/restic-backups-fw/includes: no such file or directory
Nov 01 05:28:29 fw systemd[1]: restic-backups-fw.service: Main process exited, code=exited, status=1/FAILURE
Nov 01 05:28:29 fw systemd[1]: restic-backups-fw.service: Failed with result 'exit-code'.
Nov 01 05:28:29 fw systemd[1]: Failed to start restic-backups-fw.service.

@robryk
Copy link
Contributor

robryk commented Nov 1, 2023 via email

@hughobrien hughobrien changed the title Restic: Service assumes --from-files is in use. Restic: Service assumes --files-from is in use. Nov 1, 2023
robryk added a commit to robryk/nixpkgs that referenced this issue Nov 1, 2023
Make sure that preStart and postStop are included in all cases when they are nonempty.
Janik-Haag added a commit that referenced this issue Nov 7, 2023
nixos/restic: fix #264696 and add a regression test
nyabinary pushed a commit to nyabinary/nixpkgs that referenced this issue Nov 14, 2023
Make sure that preStart and postStop are included in all cases when they are nonempty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
2 participants