more efficient backups

This commit is contained in:
Cyryl Płotnicki 2023-12-27 15:28:14 +00:00
parent bfb9fbcfc5
commit a9953689d5
2 changed files with 39 additions and 39 deletions

View file

@ -3,49 +3,48 @@
pkgs, pkgs,
... ...
}: let }: let
extraArgs = [ backupConfig = {
"--exclude='.cache'" paths = ["/home"];
"--exclude='.rustup'" exclude = [
"--exclude='.cargo'" "/home/*/Videos"
"--exclude='.config/Element/Cache'" ".cache"
"--exclude='.config/discord/Cache'" ".rustup"
]; ".cargo"
".config/Element/Cache"
".config/discord/Cache"
];
timerConfig = {OnCalendar = "hourly";};
pruneOpts = [
"--keep-hourly 25"
"--keep-daily 8"
"--keep-weekly 5"
"--keep-monthly 13"
"--keep-yearly 2"
];
checkOpts = [
"--with-cache"
];
};
niceness = { niceness = {
Nice = 19; Nice = 19;
IOSchedulingClass = "idle"; IOSchedulingClass = "idle";
}; };
in { in {
services = { services = {
restic.backups.home-to-bolty = { restic.backups.home-to-bolty =
passwordFile = "/etc/nixos/secrets/restic-password-bolty"; {
paths = ["/home"]; passwordFile = "/etc/nixos/secrets/restic-password-bolty";
repository = "rest:http://bolty:8000/"; repository = "rest:http://bolty:8000/";
timerConfig = {OnCalendar = "hourly";}; }
extraBackupArgs = extraArgs; // backupConfig;
pruneOpts = [
"--keep-hourly 25"
"--keep-daily 8"
"--keep-weekly 5"
"--keep-monthly 13"
"--keep-yearly 2"
];
};
restic.backups.home-to-b2 = { restic.backups.home-to-b2 =
passwordFile = "/etc/nixos/secrets/restic-password-b2"; {
paths = ["/home"]; passwordFile = "/etc/nixos/secrets/restic-password-b2";
repository = "b2:cyplo-restic-${config.networking.hostName}:/"; repository = "b2:cyplo-restic-${config.networking.hostName}:/";
timerConfig = {OnCalendar = "hourly";}; environmentFile = "/etc/nixos/secrets/b2-env";
extraBackupArgs = extraArgs; }
environmentFile = "/etc/nixos/secrets/b2-env"; // backupConfig;
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-bolty.serviceConfig = niceness;

View file

@ -34,9 +34,7 @@ in rec {
''; '';
timerConfig = {OnCalendar = "daily";}; timerConfig = {OnCalendar = "daily";};
environmentFile = "${config.sops.secrets.restic-backups-b2-environment.path}"; environmentFile = "${config.sops.secrets.restic-backups-b2-environment.path}";
extraBackupArgs = [ exclude = ["cache"];
"--exclude='cache'"
];
pruneOpts = [ pruneOpts = [
"--keep-hourly 25" "--keep-hourly 25"
"--keep-daily 8" "--keep-daily 8"
@ -44,6 +42,9 @@ in rec {
"--keep-monthly 13" "--keep-monthly 13"
"--keep-yearly 2" "--keep-yearly 2"
]; ];
checkOpts = [
"--with-cache"
];
}; };
}; };