|
193 | 193 |
|
194 | 194 | - name: Wait for PVC backup to complete |
195 | 195 | ansible.builtin.shell: | |
196 | | - oc wait --for=jsonpath='{.status.phase}'=Completed \ |
197 | | - backup/openstack-backup-pvcs-{{ backup_name_suffix }} \ |
198 | | - -n {{ oadp_namespace }} \ |
199 | | - --timeout={{ oadp_backup_timeout }} |
200 | | - changed_when: false |
201 | | - |
202 | | - - name: Get PVC backup status |
203 | | - ansible.builtin.shell: | |
204 | | - oc get backup openstack-backup-pvcs-{{ backup_name_suffix }} -n {{ oadp_namespace }} \ |
205 | | - -o jsonpath='{.status.phase}' |
206 | | - register: pvc_backup_status |
| 196 | + BACKUP_NAME="openstack-backup-pvcs-{{ backup_name_suffix }}" |
| 197 | + TIMEOUT={{ oadp_backup_timeout | regex_replace('[^0-9]', '') }} |
| 198 | + ELAPSED=0 |
| 199 | + while [ $ELAPSED -lt $((TIMEOUT * 60)) ]; do |
| 200 | + read -r PHASE ITEMS_DONE ITEMS_TOTAL OPS_DONE OPS_TOTAL <<< $(oc get backup ${BACKUP_NAME} -n {{ oadp_namespace }} \ |
| 201 | + -o jsonpath='{.status.phase} {.status.progress.itemsBackedUp} {.status.progress.totalItems} {.status.backupItemOperationsCompleted} {.status.backupItemOperationsAttempted}' 2>/dev/null) |
| 202 | + PROGRESS="Phase: ${PHASE:-Pending} | Items: ${ITEMS_DONE:-0}/${ITEMS_TOTAL:-?}" |
| 203 | + [ -n "${OPS_TOTAL}" ] && PROGRESS="${PROGRESS} | Operations: ${OPS_DONE:-0}/${OPS_TOTAL}" |
| 204 | + echo " $(date +%H:%M:%S) ${PROGRESS}" > /dev/tty |
| 205 | + case "${PROGRESS}" in |
| 206 | + *"Phase: Completed"*) |
| 207 | + echo "${PROGRESS}" |
| 208 | + exit 0 ;; |
| 209 | + *"Phase: Failed"*|*"Phase: PartiallyFailed"*) |
| 210 | + echo "${PROGRESS}" >&2 |
| 211 | + exit 1 ;; |
| 212 | + esac |
| 213 | + sleep 10 |
| 214 | + ELAPSED=$((ELAPSED + 10)) |
| 215 | + done |
| 216 | + echo "Timeout waiting for backup ${BACKUP_NAME} after ${TIMEOUT}m" >&2 |
| 217 | + exit 1 |
| 218 | + register: pvc_backup_progress |
207 | 219 | changed_when: false |
208 | 220 |
|
209 | 221 | - name: Print Step 2 result |
210 | 222 | ansible.builtin.debug: |
211 | | - msg: "PVC backup status: {{ pvc_backup_status.stdout }}" |
| 223 | + msg: "PVC backup: {{ pvc_backup_progress.stdout }}" |
212 | 224 |
|
213 | 225 | # ======================================== |
214 | 226 | # Step 3: OADP Resources Backup |
|
233 | 245 | - name: Pause before resources backup |
234 | 246 | ansible.builtin.pause: |
235 | 247 | prompt: >- |
236 | | - Step 2 complete: PVC backup ({{ pvc_backup_status.stdout }}). |
| 248 | + Step 2 complete: PVC backup ({{ pvc_backup_progress.stdout }}). |
237 | 249 | Press Enter to create resources backup, or Ctrl+C then 'A' to abort |
238 | 250 | when: not (auto_ack | bool) |
239 | 251 |
|
|
244 | 256 |
|
245 | 257 | - name: Wait for resources backup to complete |
246 | 258 | ansible.builtin.shell: | |
247 | | - oc wait --for=jsonpath='{.status.phase}'=Completed \ |
248 | | - backup/openstack-backup-resources-{{ backup_name_suffix }} \ |
249 | | - -n {{ oadp_namespace }} \ |
250 | | - --timeout={{ oadp_backup_timeout }} |
251 | | - changed_when: false |
252 | | - |
253 | | - - name: Get resources backup status |
254 | | - ansible.builtin.shell: | |
255 | | - oc get backup openstack-backup-resources-{{ backup_name_suffix }} -n {{ oadp_namespace }} \ |
256 | | - -o jsonpath='{.status.phase}' |
257 | | - register: resources_backup_status |
| 259 | + BACKUP_NAME="openstack-backup-resources-{{ backup_name_suffix }}" |
| 260 | + TIMEOUT={{ oadp_backup_timeout | regex_replace('[^0-9]', '') }} |
| 261 | + ELAPSED=0 |
| 262 | + while [ $ELAPSED -lt $((TIMEOUT * 60)) ]; do |
| 263 | + read -r PHASE ITEMS_DONE ITEMS_TOTAL OPS_DONE OPS_TOTAL <<< $(oc get backup ${BACKUP_NAME} -n {{ oadp_namespace }} \ |
| 264 | + -o jsonpath='{.status.phase} {.status.progress.itemsBackedUp} {.status.progress.totalItems} {.status.backupItemOperationsCompleted} {.status.backupItemOperationsAttempted}' 2>/dev/null) |
| 265 | + PROGRESS="Phase: ${PHASE:-Pending} | Items: ${ITEMS_DONE:-0}/${ITEMS_TOTAL:-?}" |
| 266 | + [ -n "${OPS_TOTAL}" ] && PROGRESS="${PROGRESS} | Operations: ${OPS_DONE:-0}/${OPS_TOTAL}" |
| 267 | + echo " $(date +%H:%M:%S) ${PROGRESS}" > /dev/tty |
| 268 | + case "${PROGRESS}" in |
| 269 | + *"Phase: Completed"*) |
| 270 | + echo "${PROGRESS}" |
| 271 | + exit 0 ;; |
| 272 | + *"Phase: Failed"*|*"Phase: PartiallyFailed"*) |
| 273 | + echo "${PROGRESS}" >&2 |
| 274 | + exit 1 ;; |
| 275 | + esac |
| 276 | + sleep 10 |
| 277 | + ELAPSED=$((ELAPSED + 10)) |
| 278 | + done |
| 279 | + echo "Timeout waiting for backup ${BACKUP_NAME} after ${TIMEOUT}m" >&2 |
| 280 | + exit 1 |
| 281 | + register: resources_backup_progress |
258 | 282 | changed_when: false |
259 | 283 |
|
260 | 284 | - name: Print Step 3 result |
261 | 285 | ansible.builtin.debug: |
262 | | - msg: "Resources backup status: {{ resources_backup_status.stdout }}" |
| 286 | + msg: "Resources backup: {{ resources_backup_progress.stdout }}" |
263 | 287 |
|
264 | 288 | # ======================================== |
265 | 289 | # Summary |
|
0 commit comments