Automatic Snapshots and such
VSA Community Forum
LeftHand VSA Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Automatic Snapshots and such Expand / Collapse
Author
Message
Posted Thursday, June 05, 2008 10:58 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Friday, August 22, 2008 2:27 PM
Posts: 5, Visits: 17
In my perfect world, we would so something like the following:

- Have an automated snapshot set up to run every four hours
- Always have the "last" snapshot made available to a central server on a given LUN
- That server could mount that LUN at any time[1] and use it to centrally back up the contents of the production server whose snapshot that was.

This seems to me like a no-brainer that the LeftHand devices SHOULD be able to automatically do this. But I'm not entirely sure HOW.

Is anyone doing something similar in your environments?


[1] being careful internally to avoid having the LUN mounted when the snapshot changes
Post #222
Posted Thursday, June 05, 2008 11:18 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Moderators
Last Login: Yesterday @ 2:22 PM
Posts: 101, Visits: 354
The every 4 hours is easy, that's just a schedule on the SAN or driven by your backup job.
For mounting the latest snapshot for backup I'll paste the current sample script on the website.
Alternatively VSS could be used to take a snapshot and mount it to your backup server right when you request it.
Don't worry about the snapshot changing. Snapshots don't. You can be actively using the real volume and backing up a snapshot on another server without issue.

There is a zip of sample scripts on our website, using that as your source would be better because what I put here will be out of date someday.
I'm just pasting the contents of the windows_snapshot_mount_most_recent_backup_pre.cmd sample. You'll need to customize this of course but should get you a good jump start.
Hope that helps.

rem @echo off
REM **************************************************
REM script to: *
REM gather needed information *
REM snapshot the volumes *
REM mount the snapshot volumes *
REM *
REM requires: *
REM Win2k or higher (tested on W2k3) *
REM MS iSCSI 1.06 or higher *
REM *
REM LeftHand Networks supplied files *
REM java runtime environment *
REM *
REM commandline.CommandLine in *
REM UI.jar *
REM *
REM this script is provided as an example only *
REM *
REM **************************************************

REM
REM LeftHand Networks SAN/iQ variable definition
SET admin_name=admin
SET admin_passwd=lefthandnetworks
SET manager_ip=A.B.C.D
SET volume_name=Volume_Name
SET volume_list=Volume_List

REM
REM volume_label variable must match the file system label in order for the drive letter mapping to work properly.
REM No other file system can have the same volume label on the Backup server.
SET volume_label=Volume-0
REM

SET softthreshold=256
SET hardthreshold=512
SET snapshot_description="Snapshot for Backup"
SET timeout=30

SET java_path="C:\Program Files\LeftHand Networks\UI\jre\bin\java.exe"
SET jar_path="C:\Program Files\LeftHand Networks\UI\UI.jar"

REM iSCSI variable definition
SET Target_Portal=A.B.C.D
SET Target_Portal_Socket=3260
SET Persistent_T_or_F=T

SET temp_file=c:\temp.tmp
SET temp_file_1=c:\temp1.tmp
SET temp_file_2=c:\temp2.tmp
SET temp_file_3=c:\temp3.tmp
SET temp_file_4=c:\temp4.tmp
SET drive_letter=J:

REM delete all temp files from last time around
del %temp_file%
del %temp_file_1%
del %temp_file_2%
del %temp_file_3%
del %temp_file_4%

REM
REM get the most recent snapshot name
%java_path% -cp %jar_path% commandline.CommandLine %admin_name% %admin_passwd% %manager_ip% get_snapshot_name %volume_name% %timeout% >%temp_file_1%
FOR /F %%i IN (%temp_file_1%) DO (set snapshot_name=%%i)

REM
REM assign the volume list to the snapshot
%java_path% -cp %jar_path% commandline.CommandLine %admin_name% %admin_passwd% %manager_ip% acl_add_vlist %snapshot_name% %volume_list% true true %timeout%

REM
REM replace special characters in the SAN/iQ snapshot name with iSCSI iqn supported characters (-)
set snapshot_name=%snapshot_name:_=-%
set snapshot_name=%snapshot_name:.=-%
echo %snapshot_name%

REM wait 15 seconds for the delete to complete
timeout 15

REM add target portal and refresh it
iscsicli addtargetportal %Target_Portal% %Target_Portal_Socket%
iscsicli refreshtargetportal %Target_Portal% %Target_Portal_Socket%
iscsicli listtargets true> %temp_file%
type %temp_file%
IF NOT %errorlevel% == 0 (
ECHO Trouble Getting Target Information
GOTO :EOF )

REM Get Target iqn Name
findstr /I "%snapshot_name%" %temp_file% > %temp_file_3%
FOR /F %%i IN (%temp_file_3%) DO (set Target_iqn=%%i)
IF NOT %errorlevel% == 0 (
ECHO Trouble Matching Up iQN Name
GOTO :EOF )

REM login to volume or snapshot
iscsicli logintarget %Target_iqn% T * * * * * * * * * * * * * * * 0
IF NOT %errorlevel% == 0 (
ECHO Trouble Connecting to Volume
GOTO :EOF )

REM assign the drive letter to the volume in question
:assign
ECHO list volume > %temp_file%
type %temp_file%
timeout 5
diskpart /s %temp_file% > %temp_file_2%
FOR /F "tokens=1,2,4" %%i IN (%temp_file_2%) DO (
Set volume_id=%%k
Set volume_no=%%i %%j
)

IF %volume_id%==%volume_label% @echo select %volume_no% >%temp_file_4%
IF %volume_id%==%volume_label% @echo assign letter=%drive_letter% >>%temp_file_4%
rem type %temp_file_4%
diskpart /s %temp_file_4%


:EOF


Adam C
Product Manager
LeftHand Networks
Post #223
Posted Thursday, June 05, 2008 11:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Friday, August 22, 2008 2:27 PM
Posts: 5, Visits: 17
Don't suppose there's a linux version of that somewhere is there?

D

Post #224
Posted Thursday, June 05, 2008 12:09 PM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Moderators
Last Login: Yesterday @ 2:22 PM
Posts: 101, Visits: 354
Nope, but you can run the java UI and CLI on a Linux box and the actual SAN/iQ cli commands should work the same.
There was only a handful of actual SAN/iQ CLI commands in that sample script you needed. The rest was windows scripting muck and mounting with windows iSCSI.

An example of the SAN/iQ command line on Linux would be like...
>[Full path to java] -cp [full path to the UI.jar) commandline.CommandLine [username] [password] [manager ip] get_snapshot_name [volume name] [timeout]

That should give you the name of the most recent snapshot.
When you get that to work you'll be able to do the other SAN/iQ command similarly.



Adam C
Product Manager
LeftHand Networks
Post #225
Posted Thursday, June 19, 2008 1:13 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Friday, August 22, 2008 2:27 PM
Posts: 5, Visits: 17
I'm finally getting around to testing this and getting the following error:

$ java -cp /opt/LeftHandNetworks/UI/UI.jar commandline.CommandLine my_username my_password my_ip_addr get_snapshot_name my_volume_name 30

(.:9450): Gtk-WARNING **: cannot open display:
$

How would do this from a cron-job, say, where you don't have an X display?

Post #239
Posted Tuesday, September 23, 2008 12:15 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Wednesday, September 24, 2008 12:05 PM
Posts: 1, Visits: 5
After testing this script a bit, it seems that the script only sets a drive letter (J: in the example) when the volume label (Volume-0 in the example) is equal to the volume label of the last disk in the diskpart output.

What if the disk you need pops up as the first disk or somewhere in the middle of the diskpart output? How can we parse the output of diskpart to select the volume number that has a matching label when the required volume is not the last one in the list?

I spent some time researching the FOR command and it's uses, but I figured I'd ask the experts before I spend too much time. The problem shows up at this line immediately after the FOR command:

IF %volume_id%==%volume_label% @echo select %volume_no% >%temp_file_4%

The command returns the following if Volume-0 is not the last entry in diskpart:
IF Volume-1 == Volume-0

Because the values don't match, the script exits without assigning a drive letter, making all the preceding steps a complete waste. Any help is much appreciated!!
Post #319
Posted Wednesday, September 24, 2008 10:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: Wednesday, September 24, 2008 10:18 AM
Posts: 1, Visits: 3

I have updated scripts. Send me an email and I will send you new scripts.

mark.bradach@lefthandnetworks.com


Mark Bradach
Sky Tech
Lefthand Networks
Post #320
« Prev Topic | Next Topic »


All times are GMT -6:00, Time now is 4:56pm

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.031. 11 queries. Compression Disabled.