backupClient: add option for SSH identity file

This commit is contained in:
Tim Schubert 2022-07-19 20:27:59 +02:00
parent fa2ff2bd39
commit d1c7a721cc
Signed by: dadada
GPG key ID: EEB8D1CE62C4DFEA

View file

@ -37,12 +37,19 @@ in
bs = { bs = {
enable = mkEnableOption "Enable backup to BS location"; enable = mkEnableOption "Enable backup to BS location";
passphrasePath = mkOption { passphrasePath = mkOption {
type = with types; nullOr str; type = types.str;
description = '' description = ''
The path to the passphrase file. The path to the passphrase file.
''; '';
default = "/var/lib/borgbackup/bs/passphrase"; default = "/var/lib/borgbackup/bs/passphrase";
}; };
sshIdentityFile = mkOption {
type = types.str;
description = ''
Path to the SSH key that is used to transmit the backup.
'';
default = "/var/lib/borgbackup/bs/id_ed25519";
};
}; };
}; };
}; };
@ -56,7 +63,7 @@ in
}; };
}; };
services.borgbackup.jobs.gs = mkIf cfg.gs { services.borgbackup.jobs.gs = {
paths = "/"; paths = "/";
exclude = backupExcludes; exclude = backupExcludes;
repo = "/backup/${config.networking.hostName}"; repo = "/backup/${config.networking.hostName}";
@ -76,13 +83,13 @@ in
startAt = "monthly"; startAt = "monthly";
} // mkIf cfg.bs.enable { } // mkIf cfg.bs.enable {
services.borgbackup.jobs.bs = mkIf cfg.bs { services.borgbackup.jobs.bs = {
paths = "/"; paths = "/";
exclude = backupExcludes; exclude = backupExcludes;
repo = "borg@backup0.dadada.li:/mnt/storage/backup/${config.networking.hostName}"; repo = "borg@backup0.dadada.li:/mnt/storage/backup/${config.networking.hostName}";
doInit = false; doInit = false;
environment = { environment = {
BORG_RSH = "ssh -i /var/lib/borgbackup/bs/id_ed25519 -o 'StrictHostKeyChecking accept-new' -o 'TCPKeepAlive=yes'"; BORG_RSH = "ssh -i ${cfg.bs.sshIdentityFile} -o 'StrictHostKeyChecking accept-new' -o 'TCPKeepAlive=yes'";
}; };
encryption = { encryption = {
mode = "repokey"; mode = "repokey";