From a9953689d5a9f26770563ccc4bca0641bc6d6c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Wed, 27 Dec 2023 15:28:14 +0000 Subject: [PATCH] more efficient backups --- nixos/backups.nix | 71 ++++++++++++++++---------------- nixos/boxes/vpsfree1/backups.nix | 7 ++-- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/nixos/backups.nix b/nixos/backups.nix index 61b65419..6fa6cdfb 100644 --- a/nixos/backups.nix +++ b/nixos/backups.nix @@ -3,49 +3,48 @@ pkgs, ... }: let - extraArgs = [ - "--exclude='.cache'" - "--exclude='.rustup'" - "--exclude='.cargo'" - "--exclude='.config/Element/Cache'" - "--exclude='.config/discord/Cache'" - ]; + backupConfig = { + paths = ["/home"]; + exclude = [ + "/home/*/Videos" + ".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 = { 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-bolty = + { + passwordFile = "/etc/nixos/secrets/restic-password-bolty"; + repository = "rest:http://bolty:8000/"; + } + // backupConfig; - 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" - ]; - }; + restic.backups.home-to-b2 = + { + passwordFile = "/etc/nixos/secrets/restic-password-b2"; + repository = "b2:cyplo-restic-${config.networking.hostName}:/"; + environmentFile = "/etc/nixos/secrets/b2-env"; + } + // backupConfig; }; systemd.services.restic-backups-home-to-bolty.serviceConfig = niceness; diff --git a/nixos/boxes/vpsfree1/backups.nix b/nixos/boxes/vpsfree1/backups.nix index 12c60442..ffe47d75 100644 --- a/nixos/boxes/vpsfree1/backups.nix +++ b/nixos/boxes/vpsfree1/backups.nix @@ -34,9 +34,7 @@ in rec { ''; timerConfig = {OnCalendar = "daily";}; environmentFile = "${config.sops.secrets.restic-backups-b2-environment.path}"; - extraBackupArgs = [ - "--exclude='cache'" - ]; + exclude = ["cache"]; pruneOpts = [ "--keep-hourly 25" "--keep-daily 8" @@ -44,6 +42,9 @@ in rec { "--keep-monthly 13" "--keep-yearly 2" ]; + checkOpts = [ + "--with-cache" + ]; }; };