HP StorageWorks Storage Mirroring Scripting Guide (T2558-96327, April 2009)

17 - 2
Using variables to create and connect a replication
set and run verification
The following script uses variables to identify the source, target, and replication set. These variables
are then used in the Storage Mirroring commands. The $connectionID variable will contain the
connection ID for the connection established. This variable can then be used to establish a verification
schedule.
Controlling a mirror using flow control
The following script uses the IF conditional, FOR loop, and WHILE loop commands. In the following
examples the FOR loop will start a mirror for all connections between 1 and 10. The IF conditional
will return the error command "mirror failed to start" if a value of 0 is not obtained. The WHILE loop
will wait for a mirror to end and disconnect as long as the returned value is less than 10. The IF
conditional will return the error message "failed to disconnect" if a value of 0 is not obtained.
$TheTarget = "beta";
$TheSource = "alpha";
$TheRepset = "DataFiles";
source $TheSource;
repset create $TheRepset;
repset rule add c:\files include, recursive;
repset rule add c:\files\users exclude;
repset rule add d:\data include, recursive;
repset save;
$ConnectionID = connect $TheRepset to $TheTarget map exact;
verify $ConnectionID sync, newer, checksum, every 12 hr;
# Start mirror for all connections 1-10. #
# Notify user of any errors. #
SOURCE alpha;
FOR $x = 1 TO 10 DO
$ret = MIRROR START $x;
IF $ret != 0 THEN
WRITE "Mirror failed to start";
WRITE $x;
WRITE $ret;
END
END
# Wait for mirror to end and disconnect all connections 1-10. #
# Notify user of any errors. #
SOURCE alpha;
$x = 1;
WHILE $x <= 10 DO
waitonmirror $x;
$ret = disconnect $X;
IF $ret != 0 THEN
WRITE "Failed to disconnect";
WRITE $x;
WRITE $ret;
END
$x = $x + 1;
END