rework backup interface to no longer need to list backups to restore them

This commit is contained in:
Jörg Thalheim
2024-03-20 07:13:01 +01:00
parent f5d32d0b22
commit 92ac151292
3 changed files with 16 additions and 38 deletions

View File

@@ -15,7 +15,7 @@ in
{
options = {
name = lib.mkOption {
type = lib.types.str;
type = lib.types.strMatching "^[a-zA-Z0-9._-]+$";
default = name;
description = "the name of the backup job";
};
@@ -96,11 +96,11 @@ in
# TODO list needs to run locally or on the remote machine
list = ''
set -efu
# we need yes here to skip the changed url verification
(${
lib.concatMapStringsSep "\n" (
dest:
''yes y | borg-job-${dest.name} list --json | jq '[.archives[] | {"name": ("${dest.repo}::" + .name), "job_name": "${dest.name}"}]' ''
# we need yes here to skip the changed url verification
''yes y | borg-job-${dest.name} list --json | jq '[.archives[] | {"name": ("${dest.name}::${dest.repo}::" + .name)}]' ''
) (lib.attrValues cfg.destinations)
}) | jq -s 'add'
'';
@@ -114,7 +114,8 @@ in
set -efu
cd /
IFS=';' read -ra FOLDER <<< "$FOLDERS"
yes y | borg-job-"$JOB_NAME" extract --list "$NAME" "''${FOLDER[@]}"
job_name=$(echo "$NAME" | cut -d'::' -f1)
yes y | borg-job-"$job_name" extract --list "$NAME" "''${FOLDER[@]}"
'';
};
};