restic: Add dedicated paths option

This commit is contained in:
SebastianStork 2025-09-02 17:05:39 +02:00
parent 2761fc8953
commit 7e25a91691
7 changed files with 19 additions and 17 deletions

View file

@ -32,7 +32,7 @@ in
custom.services.resticBackups.actual = lib.mkIf cfg.doBackups { custom.services.resticBackups.actual = lib.mkIf cfg.doBackups {
conflictingService = "actual.service"; conflictingService = "actual.service";
extraConfig.paths = [ config.services.actual.settings.dataDir ]; paths = [ config.services.actual.settings.dataDir ];
}; };
}; };
} }

View file

@ -39,7 +39,7 @@ in
custom.services.resticBackups.filebrowser = lib.mkIf cfg.doBackups { custom.services.resticBackups.filebrowser = lib.mkIf cfg.doBackups {
conflictingService = "filebrowser.service"; conflictingService = "filebrowser.service";
extraConfig.paths = with config.services.filebrowser.settings; [ paths = with config.services.filebrowser.settings; [
database database
root root
]; ];

View file

@ -89,7 +89,7 @@ in
custom.services.resticBackups.forgejo = lib.mkIf cfg.doBackups { custom.services.resticBackups.forgejo = lib.mkIf cfg.doBackups {
conflictingService = "forgejo.service"; conflictingService = "forgejo.service";
extraConfig.paths = [ config.services.forgejo.stateDir ]; paths = [ config.services.forgejo.stateDir ];
}; };
}; };
} }

View file

@ -68,14 +68,10 @@ in
custom.services.resticBackups.hedgedoc = lib.mkIf cfg.doBackups { custom.services.resticBackups.hedgedoc = lib.mkIf cfg.doBackups {
conflictingService = "hedgedoc.service"; conflictingService = "hedgedoc.service";
extraConfig.paths = paths = with config.services.hedgedoc.settings; [
let uploadsPath
hedgedocSettings = config.services.hedgedoc.settings; db.storage
in ];
[
hedgedocSettings.uploadsPath
hedgedocSettings.db.storage
];
}; };
}; };
} }

View file

@ -17,17 +17,18 @@ in
config = lib.mkIf cfg.doBackups { config = lib.mkIf cfg.doBackups {
custom.services.resticBackups.nextcloud = { custom.services.resticBackups.nextcloud = {
paths = [
"${dataDir}/data"
"${dataDir}/config/config.php"
"${dataDir}/db.dump"
];
extraConfig = { extraConfig = {
backupPrepareCommand = '' backupPrepareCommand = ''
${nextcloud-occ} maintenance:mode --on ${nextcloud-occ} maintenance:mode --on
${lib.getExe pkgs.sudo} --user=${user} ${lib.getExe' config.services.postgresql.package "pg_dump"} nextcloud --format=custom --file=${dataDir}/db.dump ${lib.getExe pkgs.sudo} --user=${user} ${lib.getExe' config.services.postgresql.package "pg_dump"} nextcloud --format=custom --file=${dataDir}/db.dump
''; '';
backupCleanupCommand = "${nextcloud-occ} maintenance:mode --off"; backupCleanupCommand = "${nextcloud-occ} maintenance:mode --off";
paths = [
"${dataDir}/data"
"${dataDir}/config/config.php"
"${dataDir}/db.dump"
];
}; };
restoreCommand = { restoreCommand = {

View file

@ -14,6 +14,10 @@ in
type = lib.types.nullOr lib.types.nonEmptyStr; type = lib.types.nullOr lib.types.nonEmptyStr;
default = null; default = null;
}; };
paths = lib.mkOption {
type = lib.types.listOf lib.types.path;
default = [ ];
};
extraConfig = lib.mkOption { extraConfig = lib.mkOption {
type = lib.types.attrsOf lib.types.anything; type = lib.types.attrsOf lib.types.anything;
default = { }; default = { };
@ -47,6 +51,7 @@ in
name: value: name: value:
lib.mkMerge [ lib.mkMerge [
{ {
inherit (value) paths;
initialize = true; initialize = true;
repository = "s3:https://s3.eu-central-003.backblazeb2.com/stork-atlas/${name}"; repository = "s3:https://s3.eu-central-003.backblazeb2.com/stork-atlas/${name}";
environmentFile = config.sops.templates."restic/environment".path; environmentFile = config.sops.templates."restic/environment".path;

View file

@ -121,7 +121,7 @@ in
custom.services.resticBackups.syncthing = lib.mkIf cfg.doBackups { custom.services.resticBackups.syncthing = lib.mkIf cfg.doBackups {
conflictingService = "syncthing.service"; conflictingService = "syncthing.service";
extraConfig.paths = [ config.services.syncthing.dataDir ]; paths = [ config.services.syncthing.dataDir ];
}; };
}; };
} }