Quantcast
Channel: VMware Communities : Popular Discussions - VMware Server Archives
Viewing all articles
Browse latest Browse all 69891

Easy backup Solution for Vmware Server on Windows

$
0
0

I know there are others out there, and probably better written, but I wanted something simple, and repeatable. Using Windows Task Scheduler, I used the following 4 scripts. Just be sure to allow enough time for each to finish before starting the next one. Also, change the variables to match your own environment. (paths, VM names, backup folder, etc)

 

#1 Deletes the old backup to make room for the new one.

#2 Suspends the VM

#3 Backs up the entire VM folder

#4 Resumes the VM

 

So easy a caveman could do it! (oh, sorry, that one's been used)

 

Delete old backup files

type: batch file (*.bat)

@echo off

ECHO Y | DEL C:\backup\*.*

/code

 

Suspend VM

type: Batch file (*.bat)

@echo off

SET Counter = 0

 

set PATH=%PATH%;C:\Program Files\VMware\VMware VmPerl Scripting API

"C:\Program Files\VMware\VMware VmPerl Scripting API\perl.exe" "C:\Program Files\VMware\VMware VmPerl Scripting API\vmware-cmd" %*

 

vmware-cmd "C:\Virtual Machines\HeatClient\Windows XP Professional.vmx" suspend

/code

 

Backup all files within a folder

type: VB Script (*.vbs)

Option Explicit

'Declare variables

Dim strVMName, strVMFolder, strToday

Dim strBackupFolder, strBackupFile

Dim strJobName, strDescription, strNTBackupCommand

Dim objVirtualServer, objVirtualMachine, objShell, errBackup

 

'Load current date (formatted as mm-dd-yyyy)

'into variable strToday

strToday = Month(Date) & "-" & Day(Date) & "-" & Year(Date)

 

'Define Script Variables (change the next 3 variables)

strVMName = "Windows XP Professional"

strVMFolder = """C:\Virtual Machines\HeatClient"""

strBackupFolder = "C:\Backup"

strBackupFile = Chr(34) & strBackupFolder & "\" & strVMName & "_" & strToday & ".bkf" & Chr(34)

'Chr(34) is used to

'include a quote in the string

strJobName = Chr(34) & strToday & " Full Backup" & Chr(34)

strDescription = Chr(34) & "Starting " & strToday &Chr(34)

strNTBackupCommand = "ntbackup backup " & strVMFolder & " /J " & strJobName & " /D " & strDescription & " /F " & strBackupFile

 

'Instantiate command shell object

Set objShell = WScript.CreateObject("Wscript.shell")

 

'Use ntbackup.exe to back up saved VM

errBackup = objShell.Run(strNTBackupCommand,1,True)

/code

 

Resume the suspended VM

type: Batch file (*bat)

@echo off

SET Counter = 0

 

set PATH=%PATH%;C:\Program Files\VMware\VMware VmPerl Scripting API

"C:\Program Files\VMware\VMware VmPerl Scripting API\perl.exe" "C:\Program Files\VMware\VMware VmPerl Scripting API\vmware-cmd" %*

 

vmware-cmd "C:\Virtual Machines\HeatClient\Windows XP Professional.vmx" start

/code


Viewing all articles
Browse latest Browse all 69891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>