Changes

Jump to: navigation, search

OPS235 Lab 2 - CentOS7

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

Navigation menu