2024-02-05 11:46:52 +01:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}:
|
2023-09-11 20:12:52 +02:00
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
minioCfg = config.services.minio;
|
|
|
|
|
|
|
|
borgJob = name: {
|
|
|
|
environment = {
|
|
|
|
BORG_RSH = "ssh -i ${config.sops.secrets.minio_backup_ssh_key.path}";
|
|
|
|
};
|
|
|
|
repo = "ssh://zh2088@zh2088.rsync.net/./backups/minio/${name}";
|
|
|
|
compression = "zstd,10";
|
|
|
|
startAt = "*-*-* 02:30:00";
|
|
|
|
extraInitArgs = "--make-parent-dirs";
|
|
|
|
archiveBaseName = name;
|
|
|
|
|
|
|
|
encryption = {
|
|
|
|
mode = "repokey-blake2";
|
|
|
|
passCommand = "cat ${config.sops.secrets.minio_backup_pass.path}";
|
|
|
|
};
|
|
|
|
|
|
|
|
prune = {
|
|
|
|
keep = {
|
|
|
|
within = "1d";
|
|
|
|
daily = 7;
|
|
|
|
weekly = 4;
|
|
|
|
monthly = -1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
services.borgbackup.jobs = mkIf minioCfg.enable {
|
|
|
|
data = borgJob "data" // {
|
|
|
|
paths = minioCfg.dataDir;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = [ pkgs.borgbackup ];
|
|
|
|
}
|