From 21376db87b031e1109357b09a0adb49213cbdf5e Mon Sep 17 00:00:00 2001 From: Kabbone Date: Sun, 29 Oct 2023 09:46:49 +0100 Subject: [PATCH] hosts: nasbak: add remote btrbk --- hosts/desktop/hardware-configuration.nix | 4 +-- hosts/jupiter/hardware-configuration.nix | 4 +-- hosts/nasbackup/hardware-configuration.nix | 34 ++++++++++++++++++++++ modules/hardware/backup.nix | 15 ++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 modules/hardware/backup.nix diff --git a/hosts/desktop/hardware-configuration.nix b/hosts/desktop/hardware-configuration.nix index 3f572a2..effb381 100644 --- a/hosts/desktop/hardware-configuration.nix +++ b/hosts/desktop/hardware-configuration.nix @@ -14,8 +14,8 @@ { imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + [ (modulesPath + "/installer/scan/not-detected.nix")] ++ + [( import ../../modules/hardware/backup.nix )]; boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ]; boot.initrd.kernelModules = [ "vfio_pci" "vfio" "vfio_iommu_type1" ]; diff --git a/hosts/jupiter/hardware-configuration.nix b/hosts/jupiter/hardware-configuration.nix index 9df0bae..f4d7d06 100644 --- a/hosts/jupiter/hardware-configuration.nix +++ b/hosts/jupiter/hardware-configuration.nix @@ -14,8 +14,8 @@ { imports = - [ (modulesPath + "/profiles/qemu-guest.nix") - ]; + [(modulesPath + "/profiles/qemu-guest.nix")] ++ + [( import ../../modules/hardware/backup.nix )]; boot.initrd.availableKernelModules = [ "uhci_hcd" "ehci_pci" "ahci" "virtio_pci" "virtio_scsi" "sr_mod" "virtio_blk" ]; boot.initrd.kernelModules = [ ]; diff --git a/hosts/nasbackup/hardware-configuration.nix b/hosts/nasbackup/hardware-configuration.nix index 8a6ea82..be9ac14 100644 --- a/hosts/nasbackup/hardware-configuration.nix +++ b/hosts/nasbackup/hardware-configuration.nix @@ -49,6 +49,7 @@ }; services.btrbk = { + extraPackages = [ pkgs.lz4 ]; instances = { hf = { onCalendar = "hourly"; @@ -72,6 +73,39 @@ }; }; }; + bak = { + stream_compress = "lz4"; + onCalendar = "weekly"; + settings = { + incremental = "yes"; + snapshot_create = "no"; + snapshot_dir = "@snapshots"; + timestamp_format = "long"; + + snapshot_preserve_min = "all"; + target_preserve_min = "no"; + target_preserve = "4w 2m"; + + ssh_identity = "/etc/btrbk/ssh/id_ed25512_btrbk"; + + volume = { + "ssh://jupiter.home.opel-online.de/mnt/snapshots/Mars" = { + target = "/mnt/nas/Backups/nas/Mars"; + subvolume = { + "@nas" = {}; + }; + }; + }; + volume = { + "ssh://jupiter.home.opel-online.de/mnt/snapshots/Pluto" = { + target = "/mnt/nas/Backups/nas/Pluto"; + subvolume = { + "@" = {}; + }; + }; + }; + }; + }; # lf = { # onCalendar = "daily"; # settings = { diff --git a/modules/hardware/backup.nix b/modules/hardware/backup.nix new file mode 100644 index 0000000..94574ee --- /dev/null +++ b/modules/hardware/backup.nix @@ -0,0 +1,15 @@ + + +{ config, lib, pkgs, ... }: + +{ + services.btrbk = { + sshAccess = [ + { + key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDU2NJ9xwYnp6/frIOv96ih8psiFcC2eOQeT+ZEMW5rq"; + roles = [ "source" "info" "send" ]; + } + ]; + extraPackages = [ pkgs.lz4 ]; + }; +}