Parameterise restic
This commit is contained in:
parent
6d0f3a9964
commit
8a63f8aac4
|
@ -6,7 +6,6 @@
|
|||
./hardware-configuration.nix
|
||||
../../modules/cpu/intel.nix
|
||||
../../modules/gpu/intel.nix
|
||||
../../modules/restic.nix
|
||||
../../modules/ssd.nix
|
||||
../../modules/libvirt.nix
|
||||
../../modules
|
||||
|
@ -16,6 +15,7 @@
|
|||
|
||||
sbruder = {
|
||||
gui = true;
|
||||
restic.enable = true;
|
||||
};
|
||||
|
||||
boot.loader.grub.device = "/dev/disk/by-id/ata-INTEL_SSDSC2KB480G7_PHYS749202D6480BGN";
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
../../modules/cpu/intel.nix
|
||||
../../modules/gpu/amd.nix
|
||||
../../modules/libvirt.nix
|
||||
../../modules/restic.nix
|
||||
../../modules/ssd.nix
|
||||
../../modules
|
||||
../../profiles/dev.nix
|
||||
|
@ -16,6 +15,7 @@
|
|||
|
||||
sbruder = {
|
||||
gui = true;
|
||||
restic.enable = true;
|
||||
};
|
||||
|
||||
boot.loader.grub.device = "/dev/disk/by-id/ata-MTFDDAK256TBN-1AR15ABHA_UFZMQ01ZR50NMM";
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
./office.nix
|
||||
./prometheus/node_exporter.nix
|
||||
./pulseaudio.nix
|
||||
./restic.nix
|
||||
./ssh.nix
|
||||
./sway.nix
|
||||
./tools.nix
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
{ pkgs, config, lib, options, ... }:
|
||||
let
|
||||
cfg = config.sbruder.restic;
|
||||
|
||||
name = "${config.networking.hostName}-system";
|
||||
excludes = [
|
||||
# General
|
||||
|
@ -44,32 +46,52 @@ let
|
|||
maybePath = path: (lib.optional (builtins.pathExists path) (toString path));
|
||||
in
|
||||
{
|
||||
services.restic.backups."${name}" = {
|
||||
passwordFile = toString (../secrets/restic_password);
|
||||
s3CredentialsFile = toString ../secrets/s3_credentials;
|
||||
repository = "s3:https://s3.eu-central-1.wasabisys.com/sbruder-restic";
|
||||
paths = lib.mkDefault (
|
||||
[ ]
|
||||
++ maybePath /data
|
||||
++ maybePath /home
|
||||
++ maybePath /srv
|
||||
++ maybePath /var
|
||||
);
|
||||
initialize = true;
|
||||
extraBackupArgs = [
|
||||
"--exclude-caches"
|
||||
"--exclude-file=${excludesFile}"
|
||||
"--verbose"
|
||||
];
|
||||
timerConfig = {
|
||||
OnCalendar = "20:00";
|
||||
RandomizedDelaySec = "2h";
|
||||
};
|
||||
options.sbruder.restic = {
|
||||
enable = lib.mkEnableOption "restic";
|
||||
timerConfig =
|
||||
lib.recursiveUpdate
|
||||
(
|
||||
(builtins.elemAt
|
||||
(builtins.elemAt
|
||||
options.services.restic.backups.type.getSubModules
|
||||
0
|
||||
).imports
|
||||
0)
|
||||
{ name = ""; }
|
||||
).options.timerConfig
|
||||
{
|
||||
default = {
|
||||
OnCalendar = "20:00";
|
||||
RandomizedDelaySec = "2h";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."restic-backups-${name}".serviceConfig = {
|
||||
"Nice" = 10;
|
||||
"IOSchedulingClass" = "best-effort";
|
||||
"IOSchedulingPriority" = 7;
|
||||
config = lib.mkIf cfg.enable {
|
||||
services.restic.backups."${name}" = {
|
||||
passwordFile = toString (../secrets/restic_password);
|
||||
s3CredentialsFile = toString ../secrets/s3_credentials;
|
||||
repository = "s3:https://s3.eu-central-1.wasabisys.com/sbruder-restic";
|
||||
paths = lib.mkDefault (
|
||||
[ ]
|
||||
++ maybePath /data
|
||||
++ maybePath /home
|
||||
++ maybePath /srv
|
||||
++ maybePath /var
|
||||
);
|
||||
initialize = true;
|
||||
extraBackupArgs = [
|
||||
"--exclude-caches"
|
||||
"--exclude-file=${excludesFile}"
|
||||
"--verbose"
|
||||
];
|
||||
timerConfig = cfg.timerConfig;
|
||||
};
|
||||
|
||||
systemd.services."restic-backups-${name}".serviceConfig = {
|
||||
"Nice" = 10;
|
||||
"IOSchedulingClass" = "best-effort";
|
||||
"IOSchedulingPriority" = 7;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue