holocron backups
This commit is contained in:
@@ -77,6 +77,7 @@
|
||||
# copyparty.enable = false;
|
||||
syncthing.enable = true;
|
||||
ensure_perms.enable = false;
|
||||
offsite.enable = true;
|
||||
zfs.enable = true;
|
||||
smb.enable = true;
|
||||
nfs.enable = true;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
./smb
|
||||
./zfs
|
||||
./syncthing
|
||||
./offsite
|
||||
# ./copyparty
|
||||
./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";
|
||||
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 {
|
||||
@@ -152,6 +167,13 @@ in {
|
||||
);
|
||||
compression = "auto,zstd";
|
||||
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";
|
||||
group = "archives";
|
||||
encryption.mode = "repokey-blake2";
|
||||
|
||||
@@ -141,7 +141,8 @@ in {
|
||||
|
||||
# add to backups
|
||||
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"];};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ in {
|
||||
};
|
||||
offsite_dir = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "lifeboat";
|
||||
default = "lifeboat/archives";
|
||||
description = "path to rsync offsite backups to";
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user