From 7f1d315135651a84d39f0512fc433f28f3bdba33 Mon Sep 17 00:00:00 2001 From: Christian Lindig Date: Thu, 21 Mar 2024 14:38:59 +0000 Subject: [PATCH] CP-46179 use -y (yes) flag to facilitate scripting We have added an interactive prompt in case the backup VDI was created by an earlier version and does not match the expected UUID. To facilitate scripting, add a -y (yes) flag that assumes a confirmation. Signed-off-by: Christian Lindig --- scripts/xe-backup-metadata | 7 +++++-- scripts/xe-restore-metadata | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/xe-backup-metadata b/scripts/xe-backup-metadata index d6dc9b877f9..47b21108b9d 100755 --- a/scripts/xe-backup-metadata +++ b/scripts/xe-backup-metadata @@ -39,6 +39,7 @@ function usage { echo " -k: Number of older backups to preserve (default: ${history_kept})" echo " -n: Just try to find a backup VDI and stop the script after that" echo " -f Force backup even when less than 10% free capacity is left on the backup VDI" + echo " -y: Assume non-interactive mode and yes to all questions" echo " -v: Verbose output" echo echo @@ -86,7 +87,8 @@ just_find_vdi=0 fs_uninitialised=0 usage_alert=90 force_backup=0 -while getopts "hvink:u:dcf" opt ; do +yes=0 +while getopts "yhvink:u:dcf" opt ; do case $opt in h) usage ;; c) create_vdi=1 ; fs_uninitialised=1 ;; @@ -96,6 +98,7 @@ while getopts "hvink:u:dcf" opt ; do d) leave_mounted=1 ;; n) just_find_vdi=1 ;; v) debug="" ;; + y) yes=1 ;; f) force_backup=1 ;; *) echo "Invalid option"; usage ;; esac @@ -159,7 +162,7 @@ function cleanup { # if we can't validate the UUID of the VDI, prompt the user if [ -n "${vdi_uuid}" ]; then - if ! validate_vdi_uuid "${sr_uuid}" "${vdi_uuid}"; then + if ! validate_vdi_uuid "${sr_uuid}" "${vdi_uuid}" && [ "$yes" -eq 0 ]; then echo "Backup VDI $vdi_uuid was most likley create by an earlier" echo "version of this code. Make sure this is a VDI that you" echo "created as we can't validate it without mounting it." diff --git a/scripts/xe-restore-metadata b/scripts/xe-restore-metadata index d9ff3d2d37e..093cd772192 100755 --- a/scripts/xe-restore-metadata +++ b/scripts/xe-restore-metadata @@ -163,7 +163,7 @@ fi trap cleanup SIGINT ERR for vdi_uuid in ${vdis}; do - if [ "${vdi_uuid}" != "${backup_vdi}" ]; then + if [ "${vdi_uuid}" != "${backup_vdi}" ] && [ "$yes" -eq 0 ]; then echo "Probing VDI ${vdi_uuid}." echo "This VDI was created with a prior version of this code." echo "Its validity can't be checked without mounting it first."