Files
loop-ops/db/registry-export-batch.sh
2026-10-27 14:29:43 +03:00

50 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Export registry rows as migrate-list lines.
#
# Usage:
# ./registry-export-batch.sh wave1-lm
# ./registry-export-batch.sh wave1-lm -o /tmp/w1.txt
# ./registry-export-batch.sh wave1-lm --status pending,sized
# ./registry-export-batch.sh --target loop-cnpg-lm --status sized
set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1091
source "${DIR}/lib.sh"
BATCH=""
STATUS="pending,sized,failed,size_error"
TARGET=""
OUT="-"
SKIP_DONE=1
while [[ $# -gt 0 ]]; do
case "$1" in
--status) STATUS="${2:-}"; shift 2 ;;
--target) TARGET="${2:-}"; shift 2 ;;
--include-done) SKIP_DONE=0; shift ;;
-o|--output) OUT="${2:-}"; shift 2 ;;
-h|--help)
sed -n '2,10p' "$0"
exit 0
;;
*)
if [[ -z "$BATCH" && "$1" != --* ]]; then
BATCH="$1"
shift
else
die "unknown arg: $1"
fi
;;
esac
done
args=()
[[ -n "$BATCH" ]] && args+=(--batch "$BATCH")
[[ -n "$STATUS" ]] && args+=(--status "$STATUS")
[[ -n "$TARGET" ]] && args+=(--target "$TARGET")
[[ "$SKIP_DONE" -eq 1 ]] && args+=(--skip-done)
args+=(-o "$OUT")
python3 "${DIR}/registry_lib.py" --registry "${REGISTRY_PATH}" export "${args[@]}"