VirtualBox
VirtualBox
- 가상머신 실행 하기
- /usr/bin/VBoxManage startvm Ubuntu-Server -type headless
-
vmdk --> vdi 사이즈 변경
schmitt@JCock:~/Desktop/data/after/VirtualBoxIMG/AcnDbServer001$ VBoxManage clonehd "/home/schmitt//Desktop/data/after/VirtualBoxIMG/AcnDbServer001/Ubuntu1404OrgVersion_addinstalled-disk1.vmdk" "/home/schmitt/Desktop/data/after/VirtualBoxIMG/AcnDbServer001/Ubuntu1404OrgVersion_addinstall.vid" --format VDI Warning: program compiled against libxml 208 using older 207 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Clone hard disk created in format 'VDI'. UUID: 22ad08e4-737a-406e-af81-9401ce15c4ce schmitt@JCock:~/Desktop/data/after/VirtualBoxIMG/AcnDbServer001$ VBoxManage showhdinfo /home/schmitt/Desktop/data/after/VirtualBoxIMG/AcnDbServer001/Ubuntu1404OrgVersion_addinstall.vidWarning: program compiled against libxml 208 using older 207 UUID: 22ad08e4-737a-406e-af81-9401ce15c4ce Parent UUID: base State: created Type: normal (base) Location: /home/schmitt/Desktop/data/after/VirtualBoxIMG/AcnDbServer001/Ubuntu1404OrgVersion_addinstall.vid Storage format: VDI Format variant: dynamic default Capacity: 11125 MBytes Size on disk: 9013 MBytes schmitt@JCock:~/Desktop/data/after/VirtualBoxIMG/AcnDbServer001$ schmitt@JCock:~/Desktop/data/after/VirtualBoxIMG/AcnDbServer001$ schmitt@JCock:~/Desktop/data/after/VirtualBoxIMG/AcnDbServer001$ VBoxManage modifyhd "/home/schmitt/Desktop/data/after/VirtualBoxIMG/AcnDbServer001/Ubuntu1404OrgVersion_addinstall.vid" --resize 51200 Warning: program compiled against libxml 208 using older 207 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% schmitt@JCock:~/Desktop/data/after/VirtualBoxIMG/AcnDbServer001$ VBoxManage showhdinfo /home/schmitt/Desktop/data/after/VirtualBoxIMG/AcnDbServer001/Ubuntu1404OrgVersion_addinstall.vidWarning: program compiled against libxml 208 using older 207 UUID: 22ad08e4-737a-406e-af81-9401ce15c4ce Parent UUID: base State: created Type: normal (base) Location: /home/schmitt/Desktop/data/after/VirtualBoxIMG/AcnDbServer001/Ubuntu1404OrgVersion_addinstall.vid Storage format: VDI Format variant: dynamic default Capacity: 51200 MBytes Size on disk: 9013 MBytes schmitt@JCock:~/Desktop/data/after/VirtualBoxIMG/AcnDbServer001$
- 다음에 gparted를 실행하여 resize 또는 추가 볼륨을 만든다.
- snapshotAllVM.sh
1 #!/bin/sh 2 3 4 echo "\n\n" 5 echo "##############################################" 6 echo "############# MAKE SNAPSHOT START ! ##########" 7 echo "##############################################" 8 9 10 echo "\n## Virtural Images list ##" 11 allVm=$(/usr/bin/VBoxManage list vms | awk '{print($1)}') 12 for i in $allVm 13 do 14 vmname=$(echo $i | sed -e "s/\"//g") 15 echo $vmname 16 /home/smend/BackUpCenter/snapshotVM.sh $vmname 17 done 18 19 20 21 echo "\n\n" 22 echo "##############################################" 23 echo "############# MAKE SNAPSHOT END ! ############" 24 echo "##############################################" 25 echo "\n\n"
- snapshotVM.sh
1 #!/bin/sh 2 3 4 export _SDATE=$(date +"%Y%m%d%H") 5 export FinalSnapshotCnt=10 6 export FinalSnapshotDueDay=50 7 export VMNAME=$1 8 export NOW=`date +%Y%m%d%H` 9 export FinalSnapshotDay=$((NOW -$(expr $FinalSnapshotDueDay*24))) 10 11 12 echo "\n\n" 13 echo "#########################################" 14 echo "############# SNAPSHOT START ! ##########" 15 echo "#########################################" 16 echo ">> VMNAME : $1" 17 echo ">> DATE : $_SDATE" 18 echo ">> FinalBackupDay : $FinalSnapshotDueDay" 19 20 echo "\n\n" 21 echo "## Old $VMNAME snapshot delete ! ##" 22 TotalsnapshotCnt=`VBoxManage snapshot $VMNAME list | grep Name | awk '{print ($2)}' | wc -l` 23 echo ' >> Total snapshot count = ' $TotalsnapshotCnt 24 echo ' >> Final snapshot remain count = ' $FinalSnapshotCnt 25 TargetdeleteSnapshotCnt=`expr $TotalsnapshotCnt - $FinalSnapshotCnt` 26 echo ' > Total snapshot count - Final snapshot count =' $TargetdeleteSnapshotCnt 27 28 29 BackupAllFiles=$(VBoxManage snapshot $VMNAME list | grep Name | awk '{print ($2)}' | sort -n) 30 cnt=1 31 echo ' > ' $FinalSnapshotDay ' day before delete target snapshot list' 32 for i in $BackupAllFiles 33 do 34 snapshotDate=`echo $i | awk -F "-" '{print $1}'` 35 echo $cnt " : " $i 36 if [ $snapshotDate -le $FinalSnapshotDay ] 37 then 38 if [ $TargetdeleteSnapshotCnt -ge $cnt ] 39 then 40 snapshotDate=`echo $i | awk -F "-" '{print $1}'` 41 #echo $snapshotDate " vs " $FinalSnapshotDay 42 if [ $snapshotDate -le $FinalSnapshotDay ] 43 then 44 echo "Delete snapshot $i" 45 VBoxManage snapshot $1 delete $i 46 fi 47 else 48 echo " >> skip snapshot : " $i 49 fi 50 fi 51 cnt=$(expr $cnt + 1) 52 done 53 54 echo " >> Create snapshot !!" 55 VBoxManage snapshot $VMNAME take "$_SDATE-$VMNAME" --description "$_SDATE autometic snapshot from system " 56 57 58 59 echo "\n\n" 60 echo "#########################################" 61 echo "############# SNAPSHOT END ! ############" 62 echo "#########################################" 63 echo "\n\n"