add more borg options for dbs and offsite
This commit is contained in:
@@ -44,6 +44,7 @@ in {
|
|||||||
};
|
};
|
||||||
backups = {
|
backups = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
databases = false;
|
||||||
backup_repo = "/var/lib/backups/homelab";
|
backup_repo = "/var/lib/backups/homelab";
|
||||||
offsite_dir = "/lifeboat/vaniville/homelab";
|
offsite_dir = "/lifeboat/vaniville/homelab";
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,11 +26,21 @@ in {
|
|||||||
default = {};
|
default = {};
|
||||||
description = "backup jobs, nested attribute sets should be <bak_name> = paths [<list_of_paths>]";
|
description = "backup jobs, nested attribute sets should be <bak_name> = paths [<list_of_paths>]";
|
||||||
};
|
};
|
||||||
|
databases = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "if databases are present, runs dumps";
|
||||||
|
};
|
||||||
backup_repo = lib.mkOption {
|
backup_repo = lib.mkOption {
|
||||||
type = lib.types.path;
|
type = lib.types.path;
|
||||||
default = "/holocron/archives/homelab";
|
default = "/holocron/archives/homelab";
|
||||||
description = "path to take daily backups to with borg!";
|
description = "path to take daily backups to with borg!";
|
||||||
};
|
};
|
||||||
|
offsite = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = true;
|
||||||
|
description = "bool to control weather or not the repo is backed up offsite";
|
||||||
|
};
|
||||||
offsite_user = lib.mkOption {
|
offsite_user = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.str;
|
||||||
default = "lifeboat";
|
default = "lifeboat";
|
||||||
@@ -59,11 +69,11 @@ in {
|
|||||||
group = "archives";
|
group = "archives";
|
||||||
encryption.mode = "repokey-blake2";
|
encryption.mode = "repokey-blake2";
|
||||||
encryption.passCommand = "cat ${sec."borg_passwd".path}";
|
encryption.passCommand = "cat ${sec."borg_passwd".path}";
|
||||||
preHook = ''
|
preHook = lib.mkIf cfg.databases ''
|
||||||
systemctl start mysql-backup.service
|
systemctl start mysql-backup.service
|
||||||
systemctl start $(systemctl list-unit-files 'postgresqlBackup-*.service' --no-legend --no-pager | cut -d' ' -f1)
|
systemctl start $(systemctl list-unit-files 'postgresqlBackup-*.service' --no-legend --no-pager | cut -d' ' -f1)
|
||||||
'';
|
'';
|
||||||
postHook = ''
|
postHook = lib.mkIf cfg.offsite''
|
||||||
${pkgs.sshpass}/bin/sshpass -f ${sec."lifeboat_rsync".path} \
|
${pkgs.sshpass}/bin/sshpass -f ${sec."lifeboat_rsync".path} \
|
||||||
${pkgs.rsync}/bin/rsync -aHAX --partial --numeric-ids --info=progress2,name1,stats2 --delete \
|
${pkgs.rsync}/bin/rsync -aHAX --partial --numeric-ids --info=progress2,name1,stats2 --delete \
|
||||||
-e "ssh -o StrictHostKeyChecking=no" \
|
-e "ssh -o StrictHostKeyChecking=no" \
|
||||||
|
|||||||
Reference in New Issue
Block a user