From a1ce3b19bc0613aaba21d7f92ee9917c07d089ec Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 20 Sep 2026 20:57:53 -0300 Subject: [PATCH] Allow container list override in main pipeline --- README.md | 10 ++++++++++ backup.sh | 14 +++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 648ec57..c41a63c 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,16 @@ Preview all stages without stopping containers, copying, or deleting: 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: ```bash diff --git a/backup.sh b/backup.sh index 8778884..0efe826 100755 --- a/backup.sh +++ b/backup.sh @@ -3,12 +3,13 @@ set -Eeuo pipefail SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)" . "$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 case "$1" in --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) - 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." exit 0 ;; *) die "Unknown option: $1" 2 ;; @@ -19,14 +20,17 @@ require_command flock mkdir -p "$(dirname "$LOCK_FILE")" exec 9>"$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" (( SKIP_CONTAINERS )) || "$SCRIPT_DIR/stages/10-containers.sh" "${stage_args[@]}" +method_args=(); (( DRY_RUN )) && method_args+=(--dry-run) for method in $BACKUP_METHODS; do 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) [[ -n "$method_script" ]] || die "Configured backup method not found: $method" - "$method_script" "${stage_args[@]}" + "$method_script" "${method_args[@]}" 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"