VM Backup: Difference between revisions
From KlavoWiki
Jump to navigationJump to search
New page: The following script will make a compressed tar.gz file for each existing virtual computer. The compressed file is saved in /root/vmbackup/%date% <pre> #!/bin/bash # Variables used by sc... |
No edit summary |
||
Line 1: | Line 1: | ||
'''NOTE:''' Please see [[Backup_Script_for_VMware|Backup Script for VMware]] for an update version.<br><br> | |||
The following script will make a compressed tar.gz file for each existing virtual computer. The compressed file is saved in /root/vmbackup/%date% | The following script will make a compressed tar.gz file for each existing virtual computer. The compressed file is saved in /root/vmbackup/%date% | ||
Revision as of 11:28, 16 November 2008
NOTE: Please see Backup Script for VMware for an update version.
The following script will make a compressed tar.gz file for each existing virtual computer. The compressed file is saved in /root/vmbackup/%date%
#!/bin/bash # Variables used by script strCurDate=$(date +%Y%m%d) strVMWareDir="/var/lib/vmware/Virtual Machines" strTempDir="/root/vmbackup/$strCurDate/" strLogFile="/root/vmbackup/$strCurDate/vmbackup.log" mkdir -p $strTempDir echo "!!! Starting VMWare backup of $strVMWareDir/" >> $strLogFile cd "$strVMWareDir" find "$strVMWareDir"/ -iname *.vmx | while read FILE do echo "*** Suspend: $FILE" >> $strLogFile vmware-cmd "$FILE" suspend >> $strLogFile echo "*** ZIP: $FILE" >> $strLogFile strZipName=`echo "$FILE" | awk -F/ '{print $6}'`.tar.gz tar -cvzf $strTempDir/$strZipName `echo "$FILE" | awk -F/ '{print $6}'`/* >> $strLogFile echo "*** Start: $FILE" >> $strLogFile vmware-cmd "$FILE" start >> $strLogFile done echo "!!! Backup Complete"