Skip to content

Commit

Permalink
CP-46179 use -y (yes) flag to facilitate scripting
Browse files Browse the repository at this point in the history
Backport of 7f1d315

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 <[email protected]>
  • Loading branch information
Christian Lindig committed Apr 10, 2024
1 parent 559e1ad commit f0eb272
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions scripts/xe-backup-metadata
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 ;;
Expand All @@ -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
Expand Down Expand Up @@ -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."
Expand Down
2 changes: 1 addition & 1 deletion scripts/xe-restore-metadata
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,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."
Expand Down

0 comments on commit f0eb272

Please sign in to comment.