13,420
edits
Changes
no edit summary
<code style="color:#3366CC;font-family:courier;font-size:.9em;">
if [ "$answer" = "y" ] # Backup all VMs if answer is yesthen for num in 1 2 3 # Determinant loop for 3 arguments::1, 2, and 3 do echo "Backing up VM #$num" gzip < /var/lib/libvirt/images/centos$num.img > /root/centos$num.img.backup.gz echo "VM #$num BACKUP DONE" done<br>elif [ "$answer" = "n" ]::then:: read -p "Which VM should be backed up? (1/2/3): " numanswer:: until echo $numanswer | grep "^[123]$" >> /dev/null # Look for match of single digit: 1,2, or 3:: do:: read -p "Invalid Selection. Select 1, 2, or 3: " numanswer:: done:: echo "Backing up VM #$numanswer":: gzip < /var/lib/libvirt/images/centos$numanswer.img > /root/centos$numanswer.img.backup.gz:: echo "VM #$numanswer BACKUP DONE":::else:: echo "Invalid Selection... Aborting program":: exit 2::fi
</code>