Announcement

Collapse
No announcement yet.

Stop, backup and start scripts for vmware 2.0 guests on Windows 2003 host

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stop, backup and start scripts for vmware 2.0 guests on Windows 2003 host

    Hi there,

    I've the Internet for some good scripts to stop, backup and start VMware 2.0 guests. In my search I found this from the Petri IT Knowledgebase: http://www.petri.com/virtual_script_...re_servers.htm

    As mentioned in the start of the article:

    In using VMware Server, sooner or later you will have a need to script the startup and shutdown of VMware Servers! You may want to do this for backup purposes...

    Correct, I have therefore customized 3 scripts which will do the following:

    suspend.bat will Suspend VM guest OS

    Code:
    rem suspend script to stop virtual machines.
    
    rem set the path to the vmware installation
    
    cd "C:\Program Files\VMware\VMware Server"
    
    rem use correct path to vmx file
    
    vmrun -T server -h "https://localhost:8333/sdk" -u administrator -p PASSWORD suspend "[standard] Ubuntu_8.04_32-bit_server/Ubuntu_8.04_32-bit_server.vmx"
    vmrun -T server -h "https://localhost:8333/sdk" -u administrator -p PASSWORD suspend "[standard] SBS_2003_Server/SBS_2003_Server.vmx"
    robocopy.bat will backup your suspended VM guest OS to a folder you decide and will make a logfile. You will need to have the Windows Server 2003 Resource Kit Tools installed on the server in order to use robocopy - please read the robocopy.doc on your server, once installed, if you need other backup designs/strategies.

    Please note the changed path where my VM's are living - I had some problems with robocopy.exe when there was space in the path - therefore the underscores.

    Code:
    rem makes a backup of your suspended Virtual Machines with robocopy and creates a logfile in 
    rem directory where the bat file is living
    
    robocopy C:\Virtual_Machines C:\backups\Virtual_Machines /S /E /ZB /LOG:robocopy_log.txt
    robocopy logfile:



    start.bat will start your suspended VM guest OS again.

    Code:
    rem startup script to start virtual machines.
    
    rem set the path to the vmware installation
    
    cd "C:\Program Files\VMware\VMware Server"
    
    vmrun -T server -h "https://localhost:8333/sdk" -u administrator -p PASSWORD start "[standard] Ubuntu_8.04_32-bit_server/Ubuntu_8.04_32-bit_server.vmx"
    
    vmrun -T server -h "https://localhost:8333/sdk" -u administrator -p PASSWORD start "[standard] SBS_2003_Server/SBS_2003_Server.vmx"
    I use scheduled tasks to control the bat jobs.

    the suspend.bat is scheduled to run 01:00 in the night

    The robocopy.bat is scheduled to run 01:15 in the night

    the start.bat is scheduled to run 02:30 in the night

    Right now the backup takes 10 minutes as this is a new configuration, but your installation will grove over time, keep that in mind, when you set the start time

    the Windows SBS 2008 R2 Standard server is a full configured SBS with Exchange, Shared files, faxes.

    The Ubuntu 8.04 is the smtp server for Exchange, setup as a Spam and virus snake + adding disclaimer to all outgoing emails.

    I have zipped the 3 bat files and a copy of my logfile.

    My wishes for future optimizing the scripts is:

    1. Mail after the robocopy has run with the logfile attached, and subject saying either success or failure.
    2. robocopy should dump backups on NAS


    Please be gentle with this post, as I'm a newbie in windows server administration, and in this forum (has been warned once )
    Attached Files

  • #2
    Re: Stop, backup and start scripts for vmware 2.0 guests on Windows 2003 host

    A few points.

    Robocopy is reliable a tool, not a fast one. Therefore copying files will take more time, as each file is verified. Consider using (x?)copy to copy the files on another a local disk. Robocopy could be used with NAS copies.

    You could use the double quote character " around paths to handle spaces. That is "c:\my virtual machines" instead of renaming the directory to c:\my_virtual_machines.

    Wouldn't it be more useful to have just one script that loops through virtual machines and performs a stop-backup-start operation for each machine? This way you would have more uptime (each system is down just for the specific backup, not for the whole backup perioid), and wouldn't have to worry about starting the machines during copy operations.

    For the emal part, consider usig Mapisend or Blat. Some VBScript / Powershell can do the trick too, but then you should consider moving the whole script onto either language. Controlling VMWare via scripts can be done with the scripting API.

    -vP

    Comment

    Working...
    X