holocron backups

This commit is contained in:
2026-06-20 15:15:08 -05:00
parent a8811af514
commit ab2f0a6e6a
6 changed files with 91 additions and 2 deletions
+1
View File
@@ -77,6 +77,7 @@
# copyparty.enable = false; # copyparty.enable = false;
syncthing.enable = true; syncthing.enable = true;
ensure_perms.enable = false; ensure_perms.enable = false;
offsite.enable = true;
zfs.enable = true; zfs.enable = true;
smb.enable = true; smb.enable = true;
nfs.enable = true; nfs.enable = true;
+1
View File
@@ -11,6 +11,7 @@
./smb ./smb
./zfs ./zfs
./syncthing ./syncthing
./offsite
# ./copyparty # ./copyparty
./perms ./perms
]; ];
@@ -0,0 +1,64 @@
{
config,
pkgs,
lib,
...
}: let
service = "holocron_offsite";
cfg = config.holocron.${service};
in {
options.holocron.ensure_perms = {
enable = lib.mkEnableOption "enables backup script for holocron fileshare";
paths = lib.mkOption {
type = with lib.types; listOf str;
default = [
"/holocron/srv"
];
description = "list of paths to backup";
};
offsite_user = lib.mkOption {
type = lib.types.str;
default = "lifeboat";
description = "user to connect to offsite host with";
};
offsite_target = lib.mkOption {
type = lib.types.str;
default = "lifeboat.holocron.blue";
description = "ip or domain for offsite backups";
};
offsite_dir = lib.mkOption {
type = lib.types.str;
default = "lifeboat/holocron";
description = "path to rsync offsite backups to";
};
};
config = lib.mkIf cfg.enable {
systemd.services.${service} = {
description = "holocron daily sync";
serviceConfig = {
Type = "oneshot";
};
script = ''
${pkgs.sshpass}/bin/sshpass -f ${sec."lifeboat_rsync".path} \
${pkgs.rsync}/bin/rsync -aHAX --partial --numeric-ids --info=progress2,name1,stats2 --delete \
-e "ssh -o StrictHostKeyChecking=no" \
${builtins.concatStringsSep " " cfg.paths} \
${cfg.offsite_user}@${cfg.offsite_target}::${cfg.offsite_dir}
'';
};
systemd.timers.${service} = {
description = "timer for ${service}";
wantedBy = ["timers.target"];
timerConfig = {
OnCalendar = "*-*-* 05:00:00";
Persistent = true;
};
};
};
}
@@ -58,6 +58,21 @@ in {
default = "/holocron/archives/gameservers/minecraft/recpro_stack"; default = "/holocron/archives/gameservers/minecraft/recpro_stack";
description = "path to take hourly backups to with borg!"; description = "path to take hourly backups to with borg!";
}; };
offsite_user = lib.mkOption {
type = lib.types.str;
default = "lifeboat";
description = "user to connect to offsite host with";
};
offsite_target = lib.mkOption {
type = lib.types.str;
default = "lifeboat.holocron.blue";
description = "ip or domain for offsite backups";
};
offsite_dir = lib.mkOption {
type = lib.types.str;
default = "lifeboat/archives/gameservers";
description = "path to rsync offsite backups to";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@@ -152,6 +167,13 @@ in {
); );
compression = "auto,zstd"; compression = "auto,zstd";
preHook = "systemctl start mysql-backup.service"; preHook = "systemctl start mysql-backup.service";
postHook = ''
${pkgs.sshpass}/bin/sshpass -f ${sec."lifeboat_rsync".path} \
${pkgs.rsync}/bin/rsync -aHAX --partial --numeric-ids --info=progress2,name1,stats2 --delete \
-e "ssh -o StrictHostKeyChecking=no" \
${toString cfg.backup_repo} \
${cfg.offsite_user}@${cfg.offsite_target}::${cfg.offsite_dir}
'';
startAt = "*-*-* *:00:00"; startAt = "*-*-* *:00:00";
group = "archives"; group = "archives";
encryption.mode = "repokey-blake2"; encryption.mode = "repokey-blake2";
+2 -1
View File
@@ -141,7 +141,8 @@ in {
# add to backups # add to backups
homelab.backups.baks = { homelab.backups.baks = {
${service} = {paths = [cfg.data_dir "/var/lib/redis-immich" "/var/backup/postgresql/immich.sql.zstd"];}; ${service} = {paths = ["/var/lib/redis-immich" "/var/backup/postgresql/immich.sql.zstd"];};
#${service} = {paths = [cfg.data_dir "/var/lib/redis-immich" "/var/backup/postgresql/immich.sql.zstd"];};
}; };
}; };
} }
+1 -1
View File
@@ -43,7 +43,7 @@ in {
}; };
offsite_dir = lib.mkOption { offsite_dir = lib.mkOption {
type = lib.types.str; type = lib.types.str;
default = "lifeboat"; default = "lifeboat/archives";
description = "path to rsync offsite backups to"; description = "path to rsync offsite backups to";
}; };
}; };