summary refs log tree commit diff stats
path: root/sys/services/restic/default.nix
blob: a1bcdf65ad6a4a9ecddd020b7d999bc70c8d835f (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
{
  config,
  pkgs,
  ...
}: {
  services.restic.backups = let
    snapshotDir = "/srv/snapshots";
    homeDir = "${snapshotDir}/home";
    boxUser = "u384702-sub1";
  in {
    storagebox = {
      initialize = true;
      backupPrepareCommand = ''
        [ -d /srv/snapshots/home ] && ${pkgs.btrfs-progs}/bin/btrfs subvolume delete /srv/snapshots/home; ${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r /home /srv/snapshots/home; [ -d /srv/snapshots/srv ] && ${pkgs.btrfs-progs}/bin/btrfs subvolume delete /srv/snapshots/srv; ${pkgs.btrfs-progs}/bin/btrfs subvolume snapshot -r /srv /srv/snapshots/srv;
      '';
      paths = [
        snapshotDir
      ];
      exclude = [
        "${homeDir}/sils/.cache"
        "${homeDir}/sils/bulk"
        "${homeDir}/sils/downloads"
      ];
      extraBackupArgs = [
        "--verbose" # Spam log
      ];
      passwordFile = config.age.secrets.resticpass.path;
      extraOptions = [
        "rclone.program='ssh -p 23 ${boxUser}@${boxUser}.your-storagebox.de -i ${config.age.secrets.resticssh.path}'"
      ];
      repository = "rclone: "; # There is only one repository served
    };
  };
}