implement backup cli for borgbackup

This commit is contained in:
lassulus
2023-12-04 17:05:37 +01:00
parent 4ace326aeb
commit e772d29f44
10 changed files with 125 additions and 53 deletions

View File

@@ -33,7 +33,7 @@ in
config = lib.mkIf cfg.enable {
services.borgbackup.jobs = lib.mapAttrs
(_: dest: {
paths = map (state: state.folder) (lib.attrValues config.clanCore.state);
paths = lib.flatten (map (state: state.folders) (lib.attrValues config.clanCore.state));
exclude = [
"*.pyc"
];
@@ -58,16 +58,23 @@ in
clanCore.backups.providers.borgbackup = {
list = ''
${lib.concatMapStringsSep "\n" (dest: ''
echo listing backups for ${dest}
borg-job-${dest} list
'') cfg.destinations}
(
export BORG_REPO=${lib.escapeShellArg dest.repo}
export BORG_RSH=${lib.escapeShellArg dest.rsh}
${lib.getExe config.services.borgbackup.package} list
)
'') (lib.attrValues cfg.destinations)}
'';
start = ''
${lib.concatMapStringsSep "\n" (dest: ''
systemctl start borgbackup-job-${dest}
'') cfg.destinations}
ssh ${config.clan.networking.deploymentAddress} -- '
${lib.concatMapStringsSep "\n" (dest: ''
systemctl start borgbackup-job-${dest.name}
'') (lib.attrValues cfg.destinations)}
'
'';
restore = ''
'';
};
};
}