aboutsummaryrefslogtreecommitdiff
path: root/profiles/restic-backup.nix
blob: 876641e4a6c36db0dd41832379ef1c90d287cd38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{ config, pkgs, ... }:
let
  restic-local = pkgs.writeShellScriptBin "restic-local" ''
    export RESTIC_REPOSITORY="/data/backups/"
    export RESTIC_PASSWORD_FILE="${config.age.secrets.restic-local-pw.path}"
    exec ${pkgs.restic}/bin/restic "$@"
  '';
in
{
  age = {
    secrets = {
      restic-local-pw = {
        file = ../secrets/restic-pw.age;
      };
    };
  };

  environment.systemPackages = [
    pkgs.restic
    restic-local
  ];

  services.restic = {
    backups = {
      local = {
        paths = [ ];
        passwordFile = config.age.secrets.restic-local-pw.path;
        repository = "/data/backups/";
        initialize = true;
        timerConfig.OnCalendar = "*-*-* *:00:00";
        timerConfig.RandomizedDelaySec = "5m";
        extraBackupArgs = [ ];
      };
    };
  };
}