2022-09-18 15:13:50 -07:00
|
|
|
# TODO:
|
|
|
|
# This currently works on a per host basis, and the host file has to define all the locations it wants to back up.
|
|
|
|
# Ideally, this would create a job for each profile instead, so the backup strategy is included in the profile regardless of host
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.mossnet.backup;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
mossnet.backup = {
|
|
|
|
enable = mkEnableOption "Backup module using borg for Anish's computer nursery";
|
|
|
|
name = lib.mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = { };
|
|
|
|
example = literalExample ''
|
|
|
|
mossnet
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
name for the backup operator
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
paths = lib.mkOption {
|
|
|
|
type = with types; listOf str;
|
|
|
|
default = { };
|
|
|
|
example = literalExample ''
|
|
|
|
[ "/home/anish/usr" ];
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
A list of folders to backup
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.borgbackup.jobs = {
|
|
|
|
"${cfg.name}" = {
|
|
|
|
paths = cfg.paths;
|
|
|
|
doInit = true;
|
|
|
|
repo = "20779@hk-s020.rsync.net:${cfg.name}";
|
|
|
|
encryption = {
|
|
|
|
mode = "repokey-blake2";
|
|
|
|
passCommand = "cat /run/agenix/borg-password";
|
|
|
|
};
|
2023-01-13 03:22:10 -08:00
|
|
|
environment = { BORG_RSH = "ssh -i /run/agenix/borg-key"; };
|
2022-09-18 15:13:50 -07:00
|
|
|
compression = "auto,lzma";
|
|
|
|
startAt = "daily";
|
|
|
|
extraArgs = "--remote-path=borg1";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|