You are browsing the archive for scripts.

Backup VMWare virtual machines

6:02 pm in Uncategorized by mikeresseler

Hey All,

A question that is asked a lot, so I thought I write about it.  Can VMWare virtual machines be protected by DPM 2010 (and also with DPM 2007 by the way :-))?  The answer is YES. How cool is that?

Here is a how-to:

To achieve this, we need VDR backup.  In the current version (1.0.2) the backup repository must be in an ‘inactive’ state when it is copied to tape.  When is it in an active state? When the following conditions are met:

  • Performing a backup

  • Performing a restore

  • During housing keeping tasks such as integrity checks or pruning of old backup restore points

Because of that, we need to make sure that the VDR is in an inactive state before copying the data to tape, or with other words, shut down the VDR application.

This guide also assumes that you have already configured your VDR appliance and that the backups are scheduled and running.

Before I get to that, I’ll first explain what the prerequisites are on the DPM protected server!  What does this mean?  It has to be done on the server that holds the backup disk for the virtual machines.

image

So far the prerequisites.  Now it is time to create all the scripts to do the job.

Number on:

Create a bat file called ShutdownVDR.bat (as example, the name is free to chose)

In this example, all scripts will be placed under c:\dpmscripts

Type the folliowing in the bat file (note! This must be on 1 line…)

%systemdirectory%\windowspowershell\v1.0\powershell.exe -PSConsoleFile “%programfiles%\VMware\Infrastructure\VSphere PowerCLI\vim.psc1” -Command <scriptname>

Or, in my example:

C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe -PSConsoleFile “C:\Program Files\VMware\Infrastructure\VSphere PowerCLI\vim.psc1” -Command C:\DPMScripts\ShutdownVDR.ps1

The thorough reader has already seen that there is a .ps1 script that needs to be created… Here it is:

Connect-VIServer -Server <vCenterIPAddress> -Protocol https -User <adminUsername> -Password <password> shutdown-vmguest <VDRApplianceName> -Confirm:$False Disconnect-VIServer -Confirm:$False

or again according to my example

Connect-VIServer -Server 192.168.1.15 -Protocol https -User svc_user -Password VerYDiffICultPasswd shutdown-vmguest MP-VDR01 -Confirm:$False Disconnect-VIServer -Confirm:$False

Enough? No, we now have our shutdown of VDR in place, now it is time to create the startup.

StartupVDR.bat

%systemdirectory%\windowspowershell\v1.0\powershell.exe -PSConsoleFile “%programfiles%\VMware\Infrastructure\VSphere PowerCLI\vim.psc1” -Command <scriptname>

StartupVDR.ps1

Connect-VIServer -Server <vCenterIPAddress> -Protocol https -User <adminUsername> -Password <password> Start-VM <VDRApplianceName> Disconnect-VIServer -Confirm:$False

Configure the protected server

Now you need to configure the protected server so that it will execute pre and post scripts when it needs to perform a backup.

You do this by editing the Scriptingconfig.xml file on that protected server.  This can be found under the agent installation directory (%programfiles%\Microsoft Data Protection Manager\DPM\Scripting\)

<?xml version="1.0" encoding="utf-8"?>

<ScriptConfiguration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/2003/dls/ScriptingConfig.xsd">

<DatasourceScriptConfig DataSourceName="<DataSource>">

<PreBackupScript><path>\<Script></PreBackupScript>

<PostBackupScript><path>\<Script></PostBackupScript>

<TimeOut>15 </DatasourceScriptConfig>

</ScriptConfiguration>

Change the path\script to the correct values.  In my case it is c:\dpmscripts\shutdownVDR.bat for prebackup and c:\dpmscripts\startupVDR.bat for postbackup

Now just create a protection group that protects the specific drive and off you go…

With a lot of thanks to my colleague Arne Peleman.

Enjoy

Cheers,

Mike

by

System Center Data Protection Manager: Cool script

7:51 pm in Uncategorized by

Hey All,

One of my colleagues is managing a rather large environment on a daily base.  He has to manage two backup solutions (HP Data Protector and SCDPM) that share one tape library.  From time to time, he need to set a tape not free in that library (Otherwise SCDPM will use that tape while it is needed for the HP solution).  To do his work faster, he created a small powershell script where he has to give the name of the slot in order to mark that tape as not free.

So here it is:

$LIB = Get-DPMLibrary -DPMServerName "<servernaam>"

$TP1 = Get-Tape -DPMLibrary $LIB

$TapeLocationList = Read-Host "Tape location (Slot-x) "

foreach ($media in $TP1)

{

if ($TapeLocationList -contains $media.Location)

{

Set-Tape -Tape $media -NotFree

Echo "Tape in $($media.Location) marked as NOT FREE."

}

else

{

Echo "Tape in location $($media.Location) is not in requested slot."

}

}

 

Enjoy

Cheers,

Mike

PS: Thanks to Steven Van der Taelen for writing this script