dotfiles/nixos/backups.nix

53 lines
1.3 KiB
Nix

{
config,
pkgs,
...
}: let
extraArgs = [
"--exclude='.cache'"
"--exclude='.rustup'"
"--exclude='.cargo'"
"--exclude='.config/Element/Cache'"
"--exclude='.config/discord/Cache'"
];
niceness = {
Nice = 19;
IOSchedulingClass = "idle";
};
in {
services = {
restic.backups.home-to-bolty = {
passwordFile = "/etc/nixos/secrets/restic-password-bolty";
paths = ["/home"];
repository = "rest:http://bolty:8000/";
timerConfig = {OnCalendar = "hourly";};
extraBackupArgs = extraArgs;
pruneOpts = [
"--keep-hourly 25"
"--keep-daily 8"
"--keep-weekly 5"
"--keep-monthly 13"
"--keep-yearly 2"
];
};
restic.backups.home-to-b2 = {
passwordFile = "/etc/nixos/secrets/restic-password-b2";
paths = ["/home"];
repository = "b2:cyplo-restic-${config.networking.hostName}:/";
timerConfig = {OnCalendar = "hourly";};
extraBackupArgs = extraArgs;
environmentFile = "/etc/nixos/secrets/b2-env";
pruneOpts = [
"--keep-hourly 25"
"--keep-daily 8"
"--keep-weekly 5"
"--keep-monthly 13"
"--keep-yearly 2"
];
};
};
systemd.services.restic-backups-home-to-bolty.serviceConfig = niceness;
systemd.services.restic-backups-home-to-b2.serviceConfig = niceness;
}