From 72a4fb4fbcc5aad68416303eb440250de2bb5f6b Mon Sep 17 00:00:00 2001 From: Felix Tenley Date: Sun, 21 Mar 2021 15:39:11 +0100 Subject: [PATCH] feat(rpi4): update restic backup config --- services/restic/rpi4.nix | 48 +++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/services/restic/rpi4.nix b/services/restic/rpi4.nix index 9b2f2b8..4af3691 100644 --- a/services/restic/rpi4.nix +++ b/services/restic/rpi4.nix @@ -1,11 +1,39 @@ { config, pkgs, ... }: -{ - services.restic.backups.rpi4 = { - initialize = true; - repository = "b2:felschr-rpi4-backup:/"; - s3CredentialsFile = "/etc/nixos/secrets/restic/b2"; - passwordFile = "/etc/nixos/secrets/restic/password"; +let + resticConfig = args@{ name, extraPruneOpts ? [ ], ... }: + assert !hasAnyAttr [ + "initialize" + "repository" + "s3CredentialsFile" + "passwordFile" + "pruneOpts" + ] args; + args // { + initialize = true; + repository = "b2:felschr-rpi4-backup:/${name}"; + s3CredentialsFile = "/etc/nixos/secrets/restic/b2"; + passwordFile = "/etc/nixos/secrets/restic/password"; + timerConfig = if (args ? timerConfig) then + args.timerConfig + else { + OnCalendar = "daily"; + }; + pruneOpts = [ + "--keep-daily 7" + "--keep-weekly 4" + "--keep-monthly 3" + "--keep-yearly 1" + ] ++ extraPruneOpts; + }; +in { + services.restic.backups.full = resticConfig { + name = "full"; + paths = [ "/home" "/var" "/etc" ]; + }; + + services.restic.backups.data = resticConfig { + name = "data"; paths = [ "/etc/nixos" "/home/felschr/.config/syncthing" @@ -19,12 +47,6 @@ "/var/lib/owntracks-recorder" ]; timerConfig = { OnCalendar = "hourly"; }; - pruneOpts = [ - "--keep-hourly 24" - "--keep-daily 7" - "--keep-weekly 4" - "--keep-monthly 3" - "--keep-yearly 1" - ]; + extraPruneOpts = [ "--keep-hourly 24" ]; }; }