From 649f6d048b654ff155c0ac06adc95f34007ebd2e Mon Sep 17 00:00:00 2001 From: wi11-holdsworth <83637728+wi11-holdsworth@users.noreply.github.com> Date: Wed, 1 Oct 2025 00:18:48 +1000 Subject: [PATCH] feat: utilise borgmatic to back up several services /srv folder immich database miniflux database paperless database syncthing database --- modules/nixos/bundles/server.nix | 12 +----------- modules/nixos/features/immich.nix | 12 ++++++++++++ modules/nixos/features/miniflux.nix | 12 ++++++++++++ modules/nixos/features/paperless.nix | 12 ++++++++++++ modules/nixos/features/syncthing.nix | 24 +++++++----------------- 5 files changed, 44 insertions(+), 28 deletions(-) diff --git a/modules/nixos/bundles/server.nix b/modules/nixos/bundles/server.nix index 7e71c78..9c9c846 100644 --- a/modules/nixos/bundles/server.nix +++ b/modules/nixos/bundles/server.nix @@ -1,7 +1,6 @@ { config, lib, - pkgs, ... }: let @@ -32,16 +31,7 @@ in users.groups.media = { }; - services.borgbackup.jobs = - import ../backup.nix "srv" - { - paths = [ "/srv" ]; - } - { - inherit config; - inherit lib; - inherit pkgs; - }; + services.borgmatic.settings.source_directories = [ "/srv" ]; }; imports = [ ]; diff --git a/modules/nixos/features/immich.nix b/modules/nixos/features/immich.nix index 9ab2e83..ab72dee 100644 --- a/modules/nixos/features/immich.nix +++ b/modules/nixos/features/immich.nix @@ -16,6 +16,18 @@ in mediaLocation = "/srv/immich"; }; + # database backup + borgmatic.settings = { + postgresql_databases = [ + { + name = "immich"; + hostname = "localhost"; + username = "root"; + password = "{credential systemd borgmatic-pg}"; + } + ]; + }; + nginx = { clientMaxBodySize = "50000M"; virtualHosts."${feature}.fi33.buzz" = { diff --git a/modules/nixos/features/miniflux.nix b/modules/nixos/features/miniflux.nix index b27615f..59bbcbd 100644 --- a/modules/nixos/features/miniflux.nix +++ b/modules/nixos/features/miniflux.nix @@ -20,6 +20,18 @@ in }; }; + # database backup + borgmatic.settings = { + postgresql_databases = [ + { + name = "miniflux"; + hostname = "localhost"; + username = "root"; + password = "{credential systemd borgmatic-pg}"; + } + ]; + }; + # reverse proxy nginx = { virtualHosts."${feature}.fi33.buzz" = { diff --git a/modules/nixos/features/paperless.nix b/modules/nixos/features/paperless.nix index 0474247..e6ea41d 100644 --- a/modules/nixos/features/paperless.nix +++ b/modules/nixos/features/paperless.nix @@ -22,6 +22,18 @@ in }; }; + # database backup + borgmatic.settings = { + postgresql_databases = [ + { + name = "paperless"; + hostname = "localhost"; + username = "root"; + password = "{credential systemd borgmatic-pg}"; + } + ]; + }; + # reverse proxy nginx = { virtualHosts."${feature}.fi33.buzz" = { diff --git a/modules/nixos/features/syncthing.nix b/modules/nixos/features/syncthing.nix index 4f74eea..cd66ad3 100644 --- a/modules/nixos/features/syncthing.nix +++ b/modules/nixos/features/syncthing.nix @@ -63,24 +63,14 @@ in }; }; - # backup - borgbackup.jobs = - # we only need one syncthing host to be backed up - # choose server because borgbackup is the most fleshed out - # on srv currently + borgmatic.settings = if userName == "srv" then - import ../backup.nix feature - { - paths = [ - "/home/srv/.config/syncthing" - "/home/srv/Sync" - ]; - } - { - inherit config; - inherit lib; - inherit pkgs; - } + { + source_directories = [ + "/home/srv/.config/syncthing" + "/home/srv/Sync" + ]; + } else null;