VMware
1 2 3 4 Previous Next 55 Replies Last post: Dec 30, 2008 5:06 AM by solsie   Go to original post
Click to view Gigaguy's profile Novice 17 posts since
Dec 2, 2007
Sorry, Posted twice.
Click to view Gigaguy's profile Novice 17 posts since
Dec 2, 2007
I was able to get it integrated. I modified the original script VM-Backup.vbs, not yours. Your script was very helpful as a reference though. I needed some of the features from the original script and it was easier to add vshadow to that script the to add the needed functionality to you script.

This script includes all the orginal functionality, and adds VShadow for minimal downtime. VShadow will mount as a drive letter. And then un-mount when the script is finished.

I did not add Zack's original VShadow code to copy without mounting a drive (Honestly, didnt see a point in having it both ways)

You will need vshadow.exe in the same directory as the script.
7-Zip must be "installed", regkeys are used to get the 7-zip path.
You CAN use the VM-Backup.ini file to pass most of the parameters you can set in the script

To use VShadow:
DefaultVMPath = "E:\Virtual Machines\" 'Relative to VMware host. Need read permissions
DefaultCopyPath = "D:\VMBackupTemp\" 'Relative to the machine running the script, UNC is OK. Need write permissions. Not used for VShadow
DefaultBackupPath = "G:\VMBackup\" 'Relative to the machine running the script, UNC is OK. Need write permissions
UseVShadow = True 'Set True to use VShadow
VShadowCopyPath = "O:\Virtual Machines\" 'This should be identical to "DefaultCopyPath" but with a different drive letter. This is the drive letter where VShadow will be mounted (O: in this case)
Attachments:
Click to view SLMHC's profile Novice 9 posts since
Jan 29, 2008

Gigaguy, Everything works great until the zip file is made. Here is the log entry:

2008-01-29_11:38:40 Starting the Zip process
+ 2008-01-29_11:38:40 Running "C:\Program Files\7-Zip\7z.exe" a -tzip "F:\VMBackup\PRTG-2008-01-29_113653.zip" "O:\vmbackuptemp\PRTG\*"+
+ 2008-01-29_11:38:40 The zip command returned result code 1+
+ 2008-01-29_11:38:40 **ERROR**: The zip command failed, no zip file was created+

The 7zip exit codes state that code 1 means "Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed."

Any ideas on how to track down and fix this issue?

-Dave

Click to view Gigaguy's profile Novice 17 posts since
Dec 2, 2007
Try creating a shadow copy and running the Zip command by itself from the prompt.

1. vshadow.exe -nw -p -script=GeneratedVarsTempScript.cmd SOURCEDRIVE
2. call GeneratedVarsTempScript.cmd
3. vshadow.exe -el=%SHADOW_ID_1%,O:
4. "C:\Program Files\7-Zip\7z.exe" a -tzip "F:\VMBackup\PRTG-2008-01-29_113653.zip" "O:\vmbackuptemp\PRTG\*"

Sounds like it may be trying to zip up the running VM, which shouldnt be the case, since its a shadow copy.
Click to view SLMHC's profile Novice 9 posts since
Jan 29, 2008
Ok, I'm daft. I now have the vshadow SDK installed. BUT...the script still isn't working. I next tried the commands you gave above. Each worked until ""C:\Program Files\7-Zip\7z.exe" a -tzip "F:\VMBackup\PRTG-2008-01-29_113653.zip" "O:\vmbackuptemp\PRTG\*". The VM wasnt copied to the vmbackuptemp dir, so I pointed it to "C:\Program Files\7-Zip\7z.exe" a -tzip "F:\VMBackup\PRTG-2008-01-29_113653.zip" "O:\Virtual Machines\PRTG\*" and it is now zipping. Although very slowly. It seems to take some time on the.lck file...

I guess this leads to an error in the config.

Click to view Gigaguy's profile Novice 17 posts since
Dec 2, 2007

Ok, so the ZIP file is getting created in the correct place now. And, this should happen after the VM is started and running. Correct? If so, then the script is working as it should. I didnt see a point in copying the file and then zipping it when it didnt affect downtime. So I set it up to zip up the files directly from the Shadow Drive.

VM shouldnt be down more than 1 min or so, correct? The zipping process itself does take a while, even longer if accross the network.

My goal was to minimize downtime of the VM.

Click to view Ben Rayner's profile Novice 7 posts since
Jan 29, 2008
Hello 1st post!

After some initial issues getting this to run on a 64bit host I am about there. I can happily run the non-vss script (v3.6) but when I run this one i get the same error as SLMHC:

+ 2008-01-29_11:38:40 The zip command returned result code 1+
+ 2008-01-29_11:38:40 **ERROR**: The zip command failed, no zip file was created+

An empty zip file is created before the error is logged.

Can SLMHC provide a bit more info on what he did to get this to work? From your post it appears that you just set the VShadowCopyPath setting to "O:\Virtual Machines". I have tried this, but no go.

The minimal VM downtime is great in this script!
Click to view Gigaguy's profile Novice 17 posts since
Dec 2, 2007

The VShadowCopyPath should be the same as your original VM path. So if you VMs are located in E:\storage\VMs the VShadowCopyPath would be O:\storage\VMs.

It sound like you already have the VShadow part working but getting a zip error. May just be a path error.


Click to view Ben Rayner's profile Novice 7 posts since
Jan 29, 2008
Thanks for the prompt reply!

Checked paths and Tested again - still same issue.

My paths are:

DefaultVMPath = "E:\Virtual Machines\"
DefaultCopyPath = "E:\VMBackupTemp\"
DefaultBackupPath = "E:\VMBackup\"
UseVShadow = True
VShadowCopyPath = "O:\Virtual Machines\"

The error in the log is:

2008-01-30_01:44:18 Starting the Zip process
2008-01-30_01:44:18 Running "C:\Program Files (x86)\7-Zip\7z.exe" a -tzip "E:\VMBackup\Backup test-2008-01-30_014239.zip" "O:\Virtual Machines\Backup test\*"
2008-01-30_01:44:18 The zip command returned result code 1
2008-01-30_01:44:18 **ERROR**: The zip command failed, no zip file was created

Using the exact same setup, but with a non-vss script (v3.6) works fine.

Any ideas?
Click to view Ben Rayner's profile Novice 7 posts since
Jan 29, 2008
Further to the above...The e-mail alert informs:

The zip command, , failed with code 1. The VMware Backup Script couldn't create E:\VMBackup\Backup test-2008-01-30_014239.zip. Please check if you have enough disk space on E:\VMBackup and run the backup script again.

There is 254GB free space and the VM is only 3.5GB.

Turning off Zip file creation (by making MakeZippedFile = False) also fails, so it's not a zip file creation issue.

The backup says it completes successfully, but a backup is not actually produced. The resulting e-mail alert is below:

      • THERE IS NOT ENOUGH FREE DISK SPACE TO BACKUP AGAIN! ***

The VMware Backup Script backed up the virtual machine 'Backup test' successfully.

Backup saved as .
VM was offline 2 minutes between 08:00:59 and 08:02:36.
The script operation was paused for 0 minutes.
The compress operation took 0 minutes.

The VM is approximately GB.
The zip file is approximately GB.
There is approximately GB free on the backup location.

Total run time was 2 minutes.
Start Time: 2008-01-30_08:00:59.
End Time: 2008-01-30_08:02:36.

Click to view SLMHC's profile Novice 9 posts since
Jan 29, 2008
I agree that copying from the VSS drive is not needed. The VM is only down for a few moments, 2 min max.

I just tried it with VShadowCopyPath = "O:\Virtual Machines\" and got a new 7zip error.

The zip command, , failed with code 2. The VMware Backup Script couldn't create F:\VMBackup\PRTG-2008-01-30_100157.zip. Please check if you have enough disk space on F:\VMBackup and run the backup script again.
Note: The uncompressed virtual machine files were NOT deleted from F:\VMBackup.

Error 2 is a Fatal Error. There currently is 62GB free space on the F: drive.

Message was edited by: SLMHC
Click to view ktlevy's profile Lurker 5 posts since
Nov 28, 2007

I'm seeing a similar issue with the statistics. Everything works ok for me with the backup and zip creation, however the VM size and disk space statistics are not getting valid information for some reason:

{size:2}
      • THERE IS NOT ENOUGH FREE DISK SPACE TO BACKUP AGAIN! ***

The VMware Backup Script backed up the virtual machine 'OSIRIS' successfully.

Backup saved as W:\IT\virtual-machines\Backups\VMware\OSIRIS-2008-01-30_135646.zip.
VM was offline 3 minutes between 13:56:48 and 13:59:59.
The script operation was paused for 0 minutes.
The compress operation took 75 minutes.

The VM is approximately GB.
The zip file is approximately 5.64 GB.
There is approximately GB free on the backup location.

Total run time was 78 minutes.
Start Time: 2008-01-30_13:56:48.
End Time: 2008-01-30_15:14:01.

      • THERE IS NOT ENOUGH FREE DISK SPACE TO BACKUP AGAIN! ***

{size}
Click to view Gigaguy's profile Novice 17 posts since
Dec 2, 2007
Here is the updated script, with the statistics showing correctly. Hopefully, that will correct some of the issues.
Attachments:
Click to view Ben Rayner's profile Novice 7 posts since
Jan 29, 2008
Thanks for the updated script Gigaguy.

I now have this working - hope the below helps a 64bit OS user somewhere. I was running this script with the below batch file to run the script in a 32bit cmd.exe:

@echo off
echo "Backing up W2k3 sample"
c:
cd\
cd WINDOWS\SysWOW64
cmd /C wscript.exe c:\vmbackup\VM-Backup.vbs sample

This batch file works on a 64bit 2003 server OS with saxa's script (http://communities.vmware.com/thread/54782) but not on this one. You get the following error below:

2008-02-01_17:46:02 Running "C:\Program Files (x86)\7-Zip\7z.exe" a -tzip "E:\VMBackup\Backup test-2008-02-01_174426.zip" "O:\Virtual Machines\Backup test\*"
2008-02-01_17:46:02 The zip command returned result code 1
2008-02-01_17:46:02 **ERROR**: The zip command failed, no zip file was created
This error also occurs if you do not have vshadow.exe in the same folder as the script.

To make this work I have to manually run the 32bit cmd.exe from the WINDOWS\SysWOW64 folder, navigate to the scipt folder and run the script from here e.g.VM-Backup.vbs sample.

Any other 64bit Windows OS users care to share how they run their script from a batch file? (I would like to add this as a scheduled task) - (EDIT) SOLUTION IS TO PUT VSHADOW.EXE IN WINDOWS\SysWOW64 folder

Message was edited by: Ben Rayner

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities