{ config, lib, pkgs, ... }: /* this module */ let cfg = config.system.backups; sec = config.sops.secrets; borg = "${pkgs.borgbackup}/bin/borg"; in { options.system.backups = { enable = lib.mkEnableOption "enables backups with borg"; baks = lib.mkOption { type = lib.types.attrsOf (lib.types.attrsOf (lib.types.listOf lib.types.path)); default = {}; description = "backup jobs, nested attribute sets should be = paths []"; }; gameserver_baks = lib.mkOption { type = lib.types.attrsOf (lib.types.attrsOf (lib.types.listOf lib.types.path)); default = {}; description = "backup jobs for game servers, nested attribute sets should be = paths []"; }; }; config = lib.mkIf (cfg.enable && cfg.baks != {}) { # mysql backups currently minecraft_recpro is the only thing using this services.mysqlBackup = lib.mkIf config.services.mysql.enable { enable = true; location = "/var/backup/mysql"; user = "root"; calendar = "*-*-* *:59:45"; # goes fast, included in back up with server dirs at **:00 compressionAlg = "zstd"; databases = config.services.mysql.ensureDatabases; # set to all databases defined in esure databases }; # postgresql backups currently immich is the only user services.postgresqlBackup = lib.mkIf config.services.postgresql.enable { # immich uses this enable = true; location = "/var/backup/postgresql"; compression = "zstd"; # optional: "xz", "zstd", "none" startAt = "03:59"; # the dump is included in a backup taken at 4:00 # currently setting this in the immich file #databases = ["immich"]; # set to all databases defined in esure databases #databases = config.services.postgresql.ensureDatabases; # set to all databases defined in esure databases }; # helpful and for scripts environment.systemPackages = with pkgs; [borgbackup tree]; }; }