blob: 774d71eee0be632381033bf5175093732d60eacf (
plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
|
{ config, lib, pkgs, ... }:
let
cfg = config.orbekk.backups;
backups.pincer = {
paths = [ "/etc/nixos" ];
doInit = true;
repo = cfg.serverLocation;
encryption = {
mode = "repokey-blake2";
passCommand = "cat ${config.age.secrets.pincer-borg-repo-key.path}";
};
environment = { BORG_RSH = "ssh -i ${config.age.secrets.pincer-borg-ssh-key.path}"; };
compression = "auto,lzma";
startAt = "daily";
};
backupJob = {
${config.networking.hostName} = backups.${config.networking.hostName};
};
in
{
options = {
orbekk.backups = {
enableServer = lib.mkEnableOption "Enable backup server";
enableClient = lib.mkEnableOption "Enable backup client";
serverLocation = lib.mkOption {
type = lib.types.str;
default = "borg@localhost:.";
};
};
};
config = {
age.secrets.pincer-borg-repo-key.file = ../secrets/pincer-borg-repo-key.age;
age.secrets.pincer-borg-ssh-key.file = ../secrets/pincer-borg-ssh-key.age;
services.borgbackup.repos = lib.mkIf cfg.enableServer {
pincer = {
authorizedKeys = [ (builtins.readFile ../secrets/pincer-borg-ssh-key.pub) ];
path = [ "/var/lib/borg-pincer" ];
};
};
services.borgbackup.jobs = lib.mkIf cfg.enableClient backupJob;
};
}
|