Open main menu

CDOT Wiki β

Changes

OPS235 Lab 2 - CentOS7

74 bytes added, 19:39, 2 April 2015
no edit summary
::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
::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
13,420
edits