add restic :3

This commit is contained in:
CherryKitten 2024-04-20 14:22:16 +02:00
parent 97f3022abe
commit 0f82688071
Signed by: sammy
GPG key ID: 98D8F75FB0658276
4 changed files with 56 additions and 0 deletions

View file

@ -4,6 +4,7 @@
../../profiles/hcloud
];
fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; };
cherrykitten.backups.enable = true;
networking = {
nameservers = [

View file

@ -0,0 +1,51 @@
{ config, pkgs, lib, ... }:
let
cfg = config.cherrykitten.backups;
hostname = config.networking.hostName;
in
{
options.cherrykitten.backups = {
enable = lib.mkEnableOption "Backups";
};
config = lib.mkIf cfg.enable {
deployment.keys = {
"restic_env" = {
destDir = "/root/keys";
keyCommand = [ "pass" "hosts/${hostname}/restic/env" ];
};
"restic_repository_file" = {
destDir = "/root/keys";
keyCommand = [ "pass" "hosts/${hostname}/restic/repository" ];
};
"restic_password_file" = {
destDir = "/root/keys";
keyCommand = [ "pass" "hosts/${hostname}/restic/password" ];
};
};
services.restic.backups = {
default = {
user = "root";
timerConfig = {
OnCalendar = "daily";
Persistent = true;
};
pruneOpts = [
"--keep-daily 14"
"--keep-weekly 6"
"--keep-monthly 24"
];
paths = [ ] ++ lib.optional (config.services.postgresql.enable) "/var/lib/postgresql";
initialize = true;
exclude = [
"cache"
".cache"
".git"
];
environmentFile = "/root/keys/restic_env";
repositoryFile = "/root/keys/restic_repository_file";
passwordFile = "/root/keys/restic_password_file";
};
};
};
}

View file

@ -0,0 +1,3 @@
{ ... }: {
imports = [ ./backups ];
}

View file

@ -2,6 +2,7 @@
imports = [
../../users/root
../../users/sammy
../../modules/nixos
inputs.home-manager.nixosModules.home-manager
];