Restic backup systemd service fails because it requires "interactive authentication"

Hi all,

I’ve been setting up automated system backups using Restic on my Nix box. Below is the contents of the relevant config file “restic.nix”:

{ config, pkgs, ... }:

{
  environment.systemPackages = with pkgs; [ restic ]; # Install the restic package
  
  # This allows the service to unlock the encrypted repo
  age.identityPaths = [ "REDACTED" ]; # Use SSH key to decrypt the repo password
  age.secrets.restic-password = {
    file = ../secrets/restic-password.age;
    owner = "silvie"; # we get permission denied if we do not do this
  };

  services.restic.backups.silvie = {
    user = "silvie"; # If we don't use our own account, the ssh key isn't present to connect to the server
    repository = "REDACTED";
    passwordFile = config.age.secrets.restic-password.path;
    createWrapper = true; # https://discourse.nixos.org/t/restic-backups-on-b2-with-nixos-agenix/36196/3
    inhibitsSleep = true;
    timerConfig = {
      OnCalendar = "daily";
      Persistent = true;
    };

    paths = [ # what to back up
      "/home/silvie"
    ];
    exclude = [ # what not to back up
      "/home/silvie/.local/share/containers" # https://discussion.fedoraproject.org/t/70837/2
      # See also ~/.resticignore
    ];
  };
}

This config worked fine yesterday; I could start the systemd service via the terminal and the backup would work as expected. I could check the systemctl status and confirm this. The wrapper that this config sets up (“restic-silvie”) works fine too – I can use it to connect to my remote restic server without needing to type in the decryption password.

However, as of today, after changing nothing, the systemd unit does not work. Whether I start the service directly or the timer starts it, I get this error in the status output:

Jul 20 20:18:58 kafka systemd[1]: Starting restic-backups-silvie.service...
Jul 20 20:18:58 kafka systemd-inhibit[3635]: Failed to inhibit: Access denied as the requested operation requires interactive authentication. However, interactive authentication has not been enabled by the calling program.
Jul 20 20:18:58 kafka systemd[1]: restic-backups-silvie.service: Main process exited, code=exited, status=1/FAILURE
Jul 20 20:18:58 kafka systemd[1]: restic-backups-silvie.service: Failed with result 'exit-code'.
Jul 20 20:18:58 kafka systemd[1]: Failed to start restic-backups-silvie.service.

The wrapper command continues to work as normal and never prompts for authentication.

Anyone have advice for figuring out why this error has started to occur, and how to mitigate it? I haven’t seen any guides mention this issue. Thanks!!

Are you sure that the user silvie can run systemd-inhibit non-interactively? If not, you can either grant silvie permission to do so, or remove inhibitsSleep = true.

1 Like

I can confirm that this was the source of the issue! Commenting out this line and rebuilding now has the service start and end correctly. Thank you!!