2022-10-30 21:06:18 +01:00
|
|
|
{ pkgs, config, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
giteaCfg = config.services.gitea;
|
|
|
|
|
|
|
|
borgJob = name: {
|
|
|
|
environment = {
|
|
|
|
BORG_RSH = "ssh -i ${config.sops.secrets.gitea_backup_ssh_key.path}";
|
|
|
|
};
|
2022-10-30 21:08:08 +01:00
|
|
|
repo = "ssh://zh2088@zh2088.rsync.net/./backups/gitea/${name}";
|
2022-10-30 21:06:18 +01:00
|
|
|
compression = "zstd,10";
|
|
|
|
startAt = "*-*-* 2,6,10,14,18,22:30:00";
|
2022-10-30 21:08:08 +01:00
|
|
|
extraInitArgs = "--make-parent-dirs";
|
2022-10-30 21:06:18 +01:00
|
|
|
|
|
|
|
encryption = {
|
|
|
|
mode = "repokey-blake2";
|
|
|
|
passCommand = "cat ${config.sops.secrets.gitea_backup_pass.path}";
|
|
|
|
};
|
|
|
|
|
|
|
|
prune = {
|
|
|
|
keep = {
|
|
|
|
within = "1d";
|
|
|
|
daily = 7;
|
|
|
|
weekly = 4;
|
|
|
|
monthly = -1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
services.borgbackup.jobs = mkIf giteaCfg.enable {
|
|
|
|
repos = borgJob "gitea" // {
|
|
|
|
paths = [ "/var/lib" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.borgbackup ];
|
|
|
|
}
|