Skip to content

Commit 7f1d315

Browse files
Christian Lindiglindig
authored andcommitted
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 <[email protected]>
1 parent c2f7456 commit 7f1d315

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

scripts/xe-backup-metadata

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ function usage {
3939
echo " -k: Number of older backups to preserve (default: ${history_kept})"
4040
echo " -n: Just try to find a backup VDI and stop the script after that"
4141
echo " -f Force backup even when less than 10% free capacity is left on the backup VDI"
42+
echo " -y: Assume non-interactive mode and yes to all questions"
4243
echo " -v: Verbose output"
4344
echo
4445
echo
@@ -86,7 +87,8 @@ just_find_vdi=0
8687
fs_uninitialised=0
8788
usage_alert=90
8889
force_backup=0
89-
while getopts "hvink:u:dcf" opt ; do
90+
yes=0
91+
while getopts "yhvink:u:dcf" opt ; do
9092
case $opt in
9193
h) usage ;;
9294
c) create_vdi=1 ; fs_uninitialised=1 ;;
@@ -96,6 +98,7 @@ while getopts "hvink:u:dcf" opt ; do
9698
d) leave_mounted=1 ;;
9799
n) just_find_vdi=1 ;;
98100
v) debug="" ;;
101+
y) yes=1 ;;
99102
f) force_backup=1 ;;
100103
*) echo "Invalid option"; usage ;;
101104
esac
@@ -159,7 +162,7 @@ function cleanup {
159162

160163
# if we can't validate the UUID of the VDI, prompt the user
161164
if [ -n "${vdi_uuid}" ]; then
162-
if ! validate_vdi_uuid "${sr_uuid}" "${vdi_uuid}"; then
165+
if ! validate_vdi_uuid "${sr_uuid}" "${vdi_uuid}" && [ "$yes" -eq 0 ]; then
163166
echo "Backup VDI $vdi_uuid was most likley create by an earlier"
164167
echo "version of this code. Make sure this is a VDI that you"
165168
echo "created as we can't validate it without mounting it."

scripts/xe-restore-metadata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ fi
163163
trap cleanup SIGINT ERR
164164

165165
for vdi_uuid in ${vdis}; do
166-
if [ "${vdi_uuid}" != "${backup_vdi}" ]; then
166+
if [ "${vdi_uuid}" != "${backup_vdi}" ] && [ "$yes" -eq 0 ]; then
167167
echo "Probing VDI ${vdi_uuid}."
168168
echo "This VDI was created with a prior version of this code."
169169
echo "Its validity can't be checked without mounting it first."

0 commit comments

Comments
 (0)