diff --git a/flake.nix b/flake.nix index f925a364..7006190e 100644 --- a/flake.nix +++ b/flake.nix @@ -80,7 +80,7 @@ checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) inputs.deploy-rs.lib; - deploy.nodes = self.pub-solar.lib.deploy.mkDeployNodes self.nixosConfigurations { + deploy.nodes = self.lib.deploy.mkDeployNodes self.nixosConfigurations { nachtigall = { sshUser = username; }; diff --git a/hosts/nachtigall/apps/forgejo.nix b/hosts/nachtigall/apps/forgejo.nix index 08fd9923..5adb700d 100644 --- a/hosts/nachtigall/apps/forgejo.nix +++ b/hosts/nachtigall/apps/forgejo.nix @@ -107,4 +107,25 @@ environment.variables = { GPG_TTY = "$(tty)"; }; + + services.restic.backups.forgejo = { + paths = [ + "/var/lib/forgejo" + "/tmp/forgejo-backup.sql" + ]; + timerConfig = { + OnCalendar = "*-*-* 02:00:00 Etc/UTC"; + # droppie will be offline if nachtigall misses the timer + Persistent = false; + }; + initialize = true; + passwordFile = config.age.secrets."restic-repo-droppie".path; + repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar"; + backupPrepareCommand = '' + ${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d gitea > /tmp/forgejo-backup.sql + ''; + backupCleanupCommand = '' + rm /tmp/forgejo-backup.sql + ''; + }; } diff --git a/hosts/nachtigall/apps/keycloak.nix b/hosts/nachtigall/apps/keycloak.nix index 9db430b0..8ca5e435 100644 --- a/hosts/nachtigall/apps/keycloak.nix +++ b/hosts/nachtigall/apps/keycloak.nix @@ -46,4 +46,24 @@ "pub.solar" = flake.inputs.keycloak-theme-pub-solar.legacyPackages.${pkgs.system}.keycloak-theme-pub-solar; }; }; + + services.restic.backups.keycloak = { + paths = [ + "/tmp/keycloak-backup.sql" + ]; + timerConfig = { + OnCalendar = "*-*-* 02:00:00 Etc/UTC"; + # droppie will be offline if nachtigall misses the timer + Persistent = false; + }; + initialize = true; + passwordFile = config.age.secrets."restic-repo-droppie".path; + repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar"; + backupPrepareCommand = '' + ${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d keycloak > /tmp/keycloak-backup.sql + ''; + backupCleanupCommand = '' + rm /tmp/keycloak-backup.sql + ''; + }; } diff --git a/hosts/nachtigall/apps/mailman.nix b/hosts/nachtigall/apps/mailman.nix index 4b79396f..55e49b5e 100644 --- a/hosts/nachtigall/apps/mailman.nix +++ b/hosts/nachtigall/apps/mailman.nix @@ -79,4 +79,21 @@ # "allauth.socialaccount.providers.gitlab" # ]) #''; + + services.restic.backups.mailman = { + paths = [ + "/var/lib/mailman" + "/var/lib/mailman-web/mailman-web.db" + "/var/lib/mailman-web/settings_local.json" + "/var/lib/postfix/conf/aliases.db" + ]; + timerConfig = { + OnCalendar = "*-*-* 02:00:00 Etc/UTC"; + # droppie will be offline if nachtigall misses the timer + Persistent = false; + }; + initialize = true; + passwordFile = config.age.secrets."restic-repo-droppie".path; + repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar"; + }; } diff --git a/hosts/nachtigall/apps/mastodon.nix b/hosts/nachtigall/apps/mastodon.nix index c1b7dfaa..55705857 100644 --- a/hosts/nachtigall/apps/mastodon.nix +++ b/hosts/nachtigall/apps/mastodon.nix @@ -93,4 +93,24 @@ OMNIAUTH_ONLY = "true"; }; }; + + services.restic.backups.mastodon = { + paths = [ + "/tmp/mastodon-backup.sql" + ]; + timerConfig = { + OnCalendar = "*-*-* 02:00:00 Etc/UTC"; + # droppie will be offline if nachtigall misses the timer + Persistent = false; + }; + initialize = true; + passwordFile = config.age.secrets."restic-repo-droppie".path; + repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar"; + backupPrepareCommand = '' + ${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d mastodon > /tmp/mastodon-backup.sql + ''; + backupCleanupCommand = '' + rm /tmp/mastodon-backup.sql + ''; + }; } diff --git a/hosts/nachtigall/apps/nextcloud.nix b/hosts/nachtigall/apps/nextcloud.nix index b93af37c..50f086b1 100644 --- a/hosts/nachtigall/apps/nextcloud.nix +++ b/hosts/nachtigall/apps/nextcloud.nix @@ -130,4 +130,25 @@ autoUpdateApps.enable = true; database.createLocally = true; }; + + services.restic.backups.nextcloud = { + paths = [ + "/var/lib/nextcloud/data" + "/tmp/nextcloud-backup.sql" + ]; + timerConfig = { + OnCalendar = "*-*-* 02:00:00 Etc/UTC"; + # droppie will be offline if nachtigall misses the timer + Persistent = false; + }; + initialize = true; + passwordFile = config.age.secrets."restic-repo-droppie".path; + repository = "yule@droppie.b12f.io:/media/internal/backups-pub-solar"; + backupPrepareCommand = '' + ${pkgs.sudo}/bin/sudo -u postgres ${pkgs.postgresql}/bin/pg_dump -d nextcloud > /tmp/nextcloud-backup.sql + ''; + backupCleanupCommand = '' + rm /tmp/nextcloud-backup.sql + ''; + }; } diff --git a/hosts/nachtigall/backups.nix b/hosts/nachtigall/backups.nix new file mode 100644 index 00000000..2495365d --- /dev/null +++ b/hosts/nachtigall/backups.nix @@ -0,0 +1,7 @@ +{ flake, ... }: { + age.secrets."restic-repo-droppie" = { + file = "${flake.self}/secrets/restic-repo-droppie.age"; + mode = "400"; + owner = "root"; + }; +} diff --git a/hosts/nachtigall/configuration.nix b/hosts/nachtigall/configuration.nix index 19b9048f..8d61f8d1 100644 --- a/hosts/nachtigall/configuration.nix +++ b/hosts/nachtigall/configuration.nix @@ -1,5 +1,9 @@ -{ config, pkgs, flake, ... }: { + flake, + config, + pkgs, + ... +}: { # Use GRUB2 as the boot loader. # We don't use systemd-boot because Hetzner uses BIOS legacy boot. boot.loader.systemd-boot.enable = false; diff --git a/hosts/nachtigall/default.nix b/hosts/nachtigall/default.nix index 9f3aabcd..de927890 100644 --- a/hosts/nachtigall/default.nix +++ b/hosts/nachtigall/default.nix @@ -7,6 +7,7 @@ ./configuration.nix ./networking.nix + ./backups.nix ./apps/nginx.nix ./apps/collabora.nix diff --git a/lib/default.nix b/lib/default.nix index d7448e45..d55c3bfd 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,7 +1,7 @@ { self, lib, inputs, ... }: { # Configuration common to all Linux systems flake = { - pub-solar.lib = let + lib = let callLibs = file: import file {inherit lib;}; in rec { ## Define your own library functions here! diff --git a/modules/users.nix b/modules/users.nix index e08a2c7a..0b9a08c8 100644 --- a/modules/users.nix +++ b/modules/users.nix @@ -29,7 +29,7 @@ file = "${flake.self}/secrets/nachtigall-root-ssh-key.age"; path = "/root/.ssh/id_ed25519"; mode = "400"; - owner = root; + owner = "root"; }; security.sudo.wheelNeedsPassword = false; diff --git a/secrets/restic-repo-droppie.age b/secrets/restic-repo-droppie.age new file mode 100644 index 00000000..11cdb63a --- /dev/null +++ b/secrets/restic-repo-droppie.age @@ -0,0 +1,27 @@ +age-encryption.org/v1 +-> ssh-ed25519 iDKjwg T5uxRdAUm+mxC5VdLsJcvA7BolM8l0cofI8V6fEUEBE +dCpeg4SheN/krKGe72jHNbdul3Lvy/AwG3dq4pY/AkM +-> ssh-ed25519 uYcDNw PGHCygBqKuORMouxi/JHzzRPeM2ON+YMOYV9E1vX+Vo +F7yp4gLrEEj4BCYwsDl2LPCCRUtbDfZ/AzAAhah4+dA +-> ssh-rsa kFDS0A +lQLfw3v75CzhrS7WyHPwU+Cm+vwrlCg7hhfKGb7J67elxh21GG/6qaZfRwWL11zc +P6G3Gt//92qBwrRuWN+G7fuhThTuEsHsqqpA8JOnNIgwfk8rNN2kTj8XbkIE7Uq8 +R5ZQplV7QTtWZ0CGBl4lu4d6cf3zdFZJw6VaDoqNmC6WjwEGw4T6maZqlEmtsEra +i1LYssPXAFbeYxa1wsD/B9pI05WrGbgpBuEpybb+9v3O+u57bLAFAC1NCsj0OKNz ++7HJe5jaC5yntOjitrIrG7hIemOR5oPn5rX4+gyhEOzGud4IyMmMRKw8+1lsSqEJ +88BLgtO1LZ+K7XA4T4uhMNzJNlibo8uhPZVcpuOHAM2mb77kyOEEnGB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