nixos-config/machines/gitea/backup.nix

45 lines
855 B
Nix
Raw Normal View History

2024-02-05 11:46:52 +01:00
{
pkgs,
config,
lib,
...
}:
2022-10-30 21:06:18 +01:00
with lib;
let
borgJob = name: {
environment = {
BORG_RSH = "ssh -i ${config.sops.secrets.gitea_backup_ssh_key.path}";
};
repo = "ssh://zh2088@zh2088.rsync.net/./backups/forgejo/${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";
2023-06-08 10:03:45 +02:00
archiveBaseName = name;
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 = {
repos = borgJob "forgejo" // {
paths = [ "/var/lib/forgejo/dump" ];
};
2022-10-30 21:06:18 +01:00
};
};
environment.systemPackages = [ pkgs.borgbackup ];
}