Allow container list override in main pipeline

This commit is contained in:
Codex authored and zorruno committed 2026-09-21 11:59:51 +12:00
1 parent 1bddfe2b3d
commit a1ce3b19bc
2 files changed
+19 -5

No files matched your search

+10
View File
@@ -113,6 +113,16 @@ Preview all stages without stopping containers, copying, or deleting:
sudo /backupdockerscripts/backup.sh --dry-run sudo /backupdockerscripts/backup.sh --dry-run
``` ```
Select a different container list for one complete pipeline run:
```bash
sudo /backupdockerscripts/backup.sh --containers containers-special.txt
```
Relative container-list paths are resolved from the repository directory;
absolute paths are also accepted. The selected list affects only the container
archive stage, after which configured transfer methods and pruning continue.
Run individual parts: Run individual parts:
```bash ```bash
+9 -5
View File
@@ -3,12 +3,13 @@
set -Eeuo pipefail set -Eeuo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)"
. "$SCRIPT_DIR/lib/common.sh" . "$SCRIPT_DIR/lib/common.sh"
DRY_RUN=0; SKIP_CONTAINERS=0; SKIP_PRUNE=0 DRY_RUN=0; SKIP_CONTAINERS=0; SKIP_PRUNE=0; CONTAINERS_OVERRIDE=""
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
--dry-run|-t) DRY_RUN=1 ;; --skip-containers) SKIP_CONTAINERS=1 ;; --skip-prune) SKIP_PRUNE=1 ;; --dry-run|-t) DRY_RUN=1 ;; --skip-containers) SKIP_CONTAINERS=1 ;; --skip-prune) SKIP_PRUNE=1 ;;
--containers|-f) CONTAINERS_OVERRIDE="${2:?Missing containers file}"; shift ;;
-h|--help) -h|--help)
echo "Usage: ${0##*/} [--dry-run] [--skip-containers] [--skip-prune]" echo "Usage: ${0##*/} [--dry-run] [--containers FILE] [--skip-containers] [--skip-prune]"
echo "Methods run in BACKUP_METHODS order. Add methods/NN-name.sh and list name in BACKUP_METHODS." echo "Methods run in BACKUP_METHODS order. Add methods/NN-name.sh and list name in BACKUP_METHODS."
exit 0 ;; exit 0 ;;
*) die "Unknown option: $1" 2 ;; *) die "Unknown option: $1" 2 ;;
@@ -19,14 +20,17 @@ require_command flock
mkdir -p "$(dirname "$LOCK_FILE")" mkdir -p "$(dirname "$LOCK_FILE")"
exec 9>"$LOCK_FILE" exec 9>"$LOCK_FILE"
flock -n 9 || die "Another backup run holds lock: $LOCK_FILE" flock -n 9 || die "Another backup run holds lock: $LOCK_FILE"
stage_args=(); (( DRY_RUN )) && stage_args+=(--dry-run) stage_args=()
(( DRY_RUN )) && stage_args+=(--dry-run)
[[ -n "$CONTAINERS_OVERRIDE" ]] && stage_args+=(--containers "$CONTAINERS_OVERRIDE")
log START "Backup pipeline for $BACKUP_HOSTNAME" log START "Backup pipeline for $BACKUP_HOSTNAME"
(( SKIP_CONTAINERS )) || "$SCRIPT_DIR/stages/10-containers.sh" "${stage_args[@]}" (( SKIP_CONTAINERS )) || "$SCRIPT_DIR/stages/10-containers.sh" "${stage_args[@]}"
method_args=(); (( DRY_RUN )) && method_args+=(--dry-run)
for method in $BACKUP_METHODS; do for method in $BACKUP_METHODS; do
method_script="" method_script=""
while IFS= read -r candidate; do method_script="$candidate"; break; done < <(find "$SCRIPT_DIR/methods" -maxdepth 1 -type f -name "*-${method}.sh" -print | sort) while IFS= read -r candidate; do method_script="$candidate"; break; done < <(find "$SCRIPT_DIR/methods" -maxdepth 1 -type f -name "*-${method}.sh" -print | sort)
[[ -n "$method_script" ]] || die "Configured backup method not found: $method" [[ -n "$method_script" ]] || die "Configured backup method not found: $method"
"$method_script" "${stage_args[@]}" "$method_script" "${method_args[@]}"
done done
(( SKIP_PRUNE )) || "$SCRIPT_DIR/stages/90-prune.sh" "${stage_args[@]}" (( SKIP_PRUNE )) || "$SCRIPT_DIR/stages/90-prune.sh" "${method_args[@]}"
log DONE "Backup pipeline completed successfully" log DONE "Backup pipeline completed successfully"