feat: enable restic for home-pc
This commit is contained in:
parent
ce07314a07
commit
99223e4ad8
4 changed files with 87 additions and 31 deletions
|
@ -6,42 +6,23 @@
|
|||
|
||||
with lib;
|
||||
with builtins;
|
||||
let
|
||||
hasAnyAttr = flip (attrset: any (flip hasAttr attrset));
|
||||
|
||||
resticConfig = args@{ name, extraPruneOpts ? [ ], ... }:
|
||||
assert !hasAnyAttr [
|
||||
"initialize"
|
||||
"repository"
|
||||
"s3CredentialsFile"
|
||||
"passwordFile"
|
||||
"pruneOpts"
|
||||
] args;
|
||||
(removeAttrs args [ "name" "extraPruneOpts" ]) // {
|
||||
initialize = true;
|
||||
repository = "b2:felschr-rpi4-backup:/${name}";
|
||||
environmentFile = "/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;
|
||||
};
|
||||
let common = import ./common.nix { inherit config lib pkgs; };
|
||||
in {
|
||||
environment.systemPackages = with pkgs; [ restic ];
|
||||
|
||||
services.restic.backups.full = resticConfig {
|
||||
name = "full";
|
||||
services.restic.backups.full = common.resticConfig {
|
||||
name = "rpi4";
|
||||
paths = [ "/etc/nixos" "/var/lib" "/home" ];
|
||||
timerConfig.OnCalendar = "0/4:00:00";
|
||||
extraPruneOpts = [ "--keep-last 6" ];
|
||||
extraOptions = [ "--exclude=/var/lib/jellyfin/transcodes" ];
|
||||
extraOptions = let
|
||||
exclude = ''
|
||||
/var/lib/lxcfs
|
||||
/var/lib/docker
|
||||
/home/*/.local/share/Trash
|
||||
/home/*/.cache
|
||||
/var/lib/jellyfin/transcodes
|
||||
'';
|
||||
in [ "--exclude=/var/lib/jellyfin/transcodes" ];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue