From dd53e869d041bbd261693ab3a1138e478ab7e2d9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 7 Apr 2026 00:36:43 +0000 Subject: [PATCH] Fix: VM selection by list number instead of raw backup ID Users were entering list number (e.g. 4) but script expected backup ID (e.g. 201). Now maps selection number to actual VM ID via temp file. Co-Authored-By: Claude Opus 4.6 (1M context) --- pharmq-setup.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/pharmq-setup.sh b/pharmq-setup.sh index 2571c22..e1565ee 100644 --- a/pharmq-setup.sh +++ b/pharmq-setup.sh @@ -397,6 +397,8 @@ vm_groups = [g for g in groups if g.get("backup-type") == "vm"] if vm_groups: print("\033[1;36m=== VM 백업 목록 ===\033[0m") + # VM ID 목록을 파일로 저장 (번호→ID 매핑) + id_list = [] for i, group in enumerate(vm_groups, 1): bid = group.get("backup-id", "N/A") count = group.get("backup-count", 0) @@ -418,12 +420,19 @@ if vm_groups: except: pass + id_list.append(str(bid)) last_str = datetime.fromtimestamp(last).strftime("%Y-%m-%d %H:%M") if last > 0 else "N/A" print(f" {i}. VM {bid:<6} - {count}개 백업 (최근: {last_str})") if comment: print(f" \033[0;90m└─ {comment}\033[0m") + + # 번호→ID 매핑 파일 저장 + with open('/tmp/pbs_vm_ids.txt', 'w') as f: + f.write('\n'.join(id_list)) else: print("VM 백업이 없습니다.") + with open('/tmp/pbs_vm_ids.txt', 'w') as f: + f.write('') PYEOF echo "" @@ -434,8 +443,20 @@ PYEOF TEMPLATE_VMID="$ARGS_VM_ID" print_ok "VM 백업 자동 선택: $TEMPLATE_VMID" else - echo -ne "${CYAN}복원할 VM 백업 ID (숫자, Enter로 건너뛰기): ${NC}" - read -r TEMPLATE_VMID /dev/null || echo "") + if [ -z "$TEMPLATE_VMID" ]; then + print_err "잘못된 번호입니다: $VM_CHOICE" + TEMPLATE_VMID="" + else + print_ok "선택: VM $TEMPLATE_VMID" + fi + else + TEMPLATE_VMID="" + fi fi if [ -z "${TEMPLATE_VMID:-}" ]; then