From 2992edffb01ef52bded059a291f9f7a5ff395b03 Mon Sep 17 00:00:00 2001 From: Gonne Date: Wed, 7 Feb 2024 15:21:15 +0100 Subject: [PATCH] Backup des Fachschaftsaccounts --- nixos/modules/borgbackup.nix | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/nixos/modules/borgbackup.nix b/nixos/modules/borgbackup.nix index d019756..c0a2931 100644 --- a/nixos/modules/borgbackup.nix +++ b/nixos/modules/borgbackup.nix @@ -1,6 +1,7 @@ { config, lib, + pkgs, ... }: let inherit @@ -56,6 +57,13 @@ in { path = "/var/lib/backups/eihort"; allowSubRepos = true; }; + fsaccount = { + authorizedKeysAppendOnly = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG+Y7fQTYdIWHehrKdk92CaJ0AisEux4OrS4nIyMstU4 FS Account Backup" + ]; + path = "/var/lib/backups/fsaccount"; + allowSubRepos = true; + }; hastur = { authorizedKeysAppendOnly = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILeDvTyOUdIPARatX0PPhHgrV1gjERWLt2Twa8E2GETb Hastur Backupsystem" @@ -99,6 +107,39 @@ in { allowSubRepos = true; }; }; + # Configure backup of files on the department's fs account + jobs.fsaccount = { + preHook = '' + mkdir -p /home/fsaccount/sicherung # Create if it does not exist + ${pkgs.rsync}/bin/rsync -e 'ssh -i /home/fsaccount/.ssh/fsaccount' -r fachschaft@gw1.mathematik.tu-darmstadt.de:/home/fachschaft/* /home/fsaccount/sicherung + ''; + paths = "/home/fsaccount/sicherung"; + encryption.mode = "none"; + environment = { + BORG_RSH = "ssh -i /home/fsaccount/.ssh/fsaccount"; + BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK = "yes"; + }; + repo = "borg@localhost:fsaccount"; + startAt = "daily"; + user = "fsaccount"; + group = "users"; + readWritePaths = ["/home/fsaccount"]; + }; + }; + environment.persistence.${config.impermanence.name} = { + users.fsaccount.directories = [ + { + directory = ".ssh"; # SSH Key with access to FS Account and Borg repo and known_hosts + mode = "u=rwx,g=,o="; + } + ]; + }; + # Extra user for FS account backup + users.users = { + fsaccount = { + description = "FS Account backup"; + isNormalUser = true; + }; }; }; }