3PAR Users Group

A Storage Administrator Community




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Script for snapshots and mounts back to windows server.
PostPosted: Wed Feb 12, 2014 2:47 pm 

Joined: Tue May 28, 2013 11:10 am
Posts: 6
Here is a script I wrote to pause a Cache' database running on a Windows host. It paused the database, snaps the virtual volume and represents back to the operating system to perform nightly backups.

diskpart can be a little flaky and presntation of the volume names can be interesting.

Wanted to thanks those that posted scripts before me, because they really helped me get this working. I'm not really much of a scripting guy.



@ECHO on
@setlocal enableextensions
:: Set the hostname of the 3par storage system here
set TPDSYSNAME=3PARSYSTEMName
:: Set the location of the pwfile you created with "setpassword -saveonly -file"
:: Ran setpassword -saveonly -file e:\scripts\scripts.pwfile (this command saves a user and password encryted in this location.
set TPDPWFILE=E:\SCRIPTS\SCRIPTS.PWFILE
:: Add the path of the 3PAR cli bin folder to your existing path
set PATH=C:\Program Files (x86)\3par\inform_cli_3.1.2\bin;%PATH%
::set OUTNAME=rcopylist.txt
set ERRORLEVEL=0
::set README=NO

::This will remove existing exported VLUNS prior to removal of the snapshot. This should
::occur after the previous nights backups have completed..

echo Removing previously exported VLUNS
:: This command will remove all exported LUNS to ServerName
::command is removevlun [options] <VV|VVSet> <LUN> <n:s:p>
cli removevlun -f P1_H_DB 10 ServerName
cli removevlun -f P1_I_WIJ 11 ServerName
cli removevlun -f P1_J 12 ServerName
cli removevlun -f P1_K 13 ServerName
timeout 20
echo.
echo.
echo --remove existing snapshot file--
::command is removevv -f(force) -snaponly VVName
:: This command will remove all snapshots created from the PRD backup files.
cli removevv -f -snaponly P1_H_DB
cli removevv -f -snaponly P1_I_WIJ
cli removevv -f -snaponly P1_J
cli removevv -f -snaponly P1_K
timeout 30

echo ---starting rescanning disks file----
timeout 5
start e:\scripts\rescan.bat
timeout 50

::echo --Freezing the Cache' PRD Databases
::echo off
CD c:\intersystems\HealthSharePRD\mgr
..\bin\cache -s. -B -V -U%%SYS ##Class(Backup.General).ExternalFreeze()
:: Note that we need to check errorlevel from highest to lowest here....
if errorlevel 5 goto CREATESNAP
if errorlevel 3 goto FAIL
echo errorlevel returned wrong value
goto END
OK
::echo Production Database is FROZEN

:CREATESNAP
echo.
echo.
echo - Production Database is Frozen
echo.
echo.
echo.---Creating Group Snap Volume of PRD Partitions---
::To create a snap group volume, provides for consistent point in time for different volumes
:: syntax: creategroupsv <copy_of_VirtualVolume>:<snapshot_VirtualVolume>
timeout 10
cli creategroupsv ServerName_H_DB:P1_H_DB ServerName_I_WIJ:P1_I_WIJ ServerName_J:P1_J ServerName_K:P1_K
timeout 50
echo.
echo.
echo Issuing command to THAW the PRD database.
:: UnThaw the Cache PRD Databases
CD c:\intersystems\HealthSharePRD\mgr
..\bin\cache -s. -B -V -U%%SYS ##Class(Backup.General).ExternalThaw()
..\bin\cache -s. -B -V -U%%SYS ##Class(Backup.General).IsWDSuspended()
if errorlevel 0 Goto Thaw
if errorlevel 1 goto Frez
goto END
:Thaw
echo.
echo.
echo Production Database has been thawed
goto MOUNTVOLUME
:Frez
echo Database did not thaw
goto ERROR
:MOUNTVOLUME
::This will export the newly created snapshot to HSTSENSEMBLEP1
echo.
echo.
echo.
echo Mouting Volume to ServerName
cli createvlun -f P1_H_DB 10 ServerName
start e:\scripts\rescan.bat
timeout 50
cli createvlun -f P1_I_WIJ 11 ServerName
start e:\scripts\rescan.bat
timeout 50
start e:\scripts\rescan.bat
cli createvlun -f P1_J 12 ServerName
start e:\scripts\rescan.bat
timeout 50
cli createvlun -f P1_K 13 ServerName
start e:\scripts\rescan.bat
timeout 50

echo ---starting rescanning disks file----
timeout 5
start e:\scripts\rescan.bat
timeout 50

echo ---starting diskpart1 batch file----
start e:\scripts\calltodiskpart1.bat
timeout 80
Goto ASSIGN1

:ASSIGN1
echo.
echo.
echo -------Writing Text files to mark drive success------------
start e:\scripts\rescan.bat
DISKPART /S E:scripts\assign6.txt > E:\scripts\logfiles\assign6.txt
timeout 15
IF EXIST W:\ echo "success" >> "W:\CacheDB.txt"
IF EXIST W:\CacheDB.txt goto ASSIGN2
IF NOT EXIST W:\CacheDB.txt goto FAIL

:ASSIGN2
DISKPART /S E:scripts\assign7.txt > E:\scripts\logfiles\assign7.txt
timeout 30
echo -------Writing Text files to mark drive success------------
IF EXIST X:\ echo "success" >> "X:\I_WIJ.txt"
IF EXIST X:\I_WIJ.txt goto ASSIGN3
IF NOT EXIST X:\I_WIJ.txt goto FAIL

:ASSIGN3
DISKPART /S E:scripts\assign8.txt > E:\scripts\logfiles\assign8.txt
timeout 30
echo -------Writing Text files to mark drive success------------
IF EXIST Y:\ echo "success" >> "Y:\J_PrimaryJournal.txt"
IF EXIST Y:\J_PrimaryJournal.txt goto ASSIGN4
IF NOT EXIST Y:\J_PrimaryJournal.txt goto FAIL

:ASSIGN4
DISKPART /S E:scripts\assign9.txt > E:\scripts\logfiles\assign9.txt
timeout 30
echo -------Writing Text files to mark drive success------------
IF EXIST Z:\ echo "success" >> "Z:\K_AlternateJournal.txt"
IF EXIST Z:\K_AlternateJournal.txt goto FINISH
IF NOT EXIST Z:\K_AlternateJournal.txt goto FAIL1

:FINISH
IF EXIST Z:\K_AlternateJournal.txt echo "SNAPSHOTS and Mount have completed, Drive Z has K_AlternateJournal.txt in it" >> "e:\blat\complete.txt
IF NOT EXIST Z:\K_AlternateJournal.txt goto FAIL
IF EXIST Z:\K_AlternateJournal.txt goto SUCCESS

:FAIL
echo .
echo.
echo SYSTEM FREEZE FAILED
e:
cd e:\blat
BLAT failure.txt -to user@email.address -f user@email.address -s "HSTSENSEMBLEP1 Snap has Failed" -server 10.X.X.X

:FAIL1
echo .
echo.
echo -------Snapshots have failed, check drive letters---------------------
e:
cd e:\blat
BLAT failure.txt -to user@email.address -f user@email.address -f user@email.address -s "HSTSENSEMBLEP1 Snap has Failed" -server 10.X.X.X

:ERROR
echo.
echo.
echo.
echo File has experienced a failure
exit

:SUCCESS
timeout 30
e:
cd e:\blat
BLAT complete.txt -to user@email.address -f user@email.address -s "HSTSENSEMBLEP1 Snap has Completed"" -server 10.X.X.X.
echo.
echo.
echo.
echo ---Snapshot and mount have completed succesfully---
exit


Top
 Profile  
Reply with quote  
 Post subject: Re: Script for snapshots and mounts back to windows server.
PostPosted: Wed Feb 12, 2014 5:35 pm 
Site Admin
User avatar

Joined: Tue Aug 18, 2009 10:35 pm
Posts: 1175
Location: Dallas, Texas
Thanks for sharing your work!

_________________
Richard Siemers
The views and opinions expressed are my own and do not necessarily reflect those of my employer.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group | DVGFX2 by: Matt