Start a Conversation

Unsolved

This post is more than 5 years old

631

April 15th, 2011 01:00

Rotating snapshots with Solutions Enabler.

I've been asked to look at how to accomplish - as part of a scripted backup - snapshots, taken at regular intervals through the day.

It's a defined number - up to 6 per day.

What I'm wanting to do, is automate the rotation process - such that I can do a recreate and activate on the 'oldest' snap.

I've been thinking in terms of using the XML output of 'synmsnap list - multi' and parsing that, as I have found a reference

"The multi-BCVs (-multi) option directs the query operation to display all BCVs

paired with the standard device; -multi lists BCV devices in chronological order."

Which got me to wondering.

It looks like - if I set up an appropriate device group - if I just do:

symsnap -g recreate

(and then an activate) it recreates the oldest snap each time.

Hence my query - if this is so, it makes my life a LOT easier, as I don't then have to script querying the 'symsnap' info, then extracting from the symdev show, the time of the last snap operation, and then use that information to control this operation.

It would make a lot of sense if it _were_ designed that way, but ... well, it'd be similarly useful to pin down if that is indeed 'by design' or if I've just been lucky for some other reason (such as sequence of device associations, or ... well, whatever).

Plan B involves use of Perl, XML::Twig, and parsing the output - of symapi commands in XML.

It'll work - I'm pretty confident of that (I can already extract and list 'assoicated' snap sessions, and their create dates with a script, and thatll be useful I think, anyway, since it'll let me see what's going on) - but it's a bit more brute force than I like, if this mechanism is already designed into Solutions Enabler.

(and before anyone suggests it, Replication manager is sadly not an option)

9 Posts

June 21st, 2011 07:00

I thought I'd update with progress so far - I think I've managed to pull together a solution.

Unfortunately I was barking up the wrong tree initially.

But what I've done now, is - using XML::Twig - pull together a script that picks out the sessions listed in a symsnap query -multi -XML

Process it, recreate the 'oldest' VDEVs, and then activate them (consistently).

I've not posted the detail of how that's done here, as it's ... rather verbose perl.

If anyone's interested, I'll do so though.

9 Posts

June 21st, 2011 07:00

It goes a bit like this:

You'll need the library XML::Twig - which you'll be able to get from CPAN.

This subroutine populates a hash called '%devices' such that you can refer to:

keys ( %devices ) to get a list of all the logical device ids in your device group.

$devices{$LDEV}{'newest'} to get the newest snap

$devices{$LDEV}{'oldest'} to get the oldest snap.

And @{ $device{$LDEV{'all'} } to get all the device IDs with snaps - again, in order.

I've omitted how to actually do the snap recreate and activate, as it shouldn't be too hard to figure out.

You'll have to handle setting $device_group yourself as well.

(Oh, and you might need to omit the -rdf. This works on a remote VDEV)

sub session_twig_parser

{

  #this is called each time the parser hits the element tag 'session' in the doodad.

  #It DOESN'T differentiate between snaps or clones - they're all 'sessions'.

  #but this should be handled by the fact you ran 'symsnap query'.

  my ( $twig, $session ) = @_;

  my $state = $session -> first_child_text('state');

  my $SRC_DEV_LD = $session -> first_child('Source') -> first_child('ld_name') -> text;

  my $TGT_DEV_LD = $session -> first_child('Target') -> first_child('ld_name') -> text;

  my $SRC_DEV_name =  $session -> first_child('Source') -> first_child_text('dev_name');

  my $TGT_DEV_name =  $session -> first_child('Target') -> first_child_text('dev_name');

    if ( $devices{$SRC_DEV_LD} )

    {

      #it already exists, so we have already 'seen' the newest LUN.

      push ( @{ $devices{$SRC_DEV_LD}{'all'} }, $TGT_DEV_LD );

      #we overwrite the 'oldest' LUN, because this one will be older than any we've seen already.

      $devices{$SRC_DEV_LD}{'oldest'} = $TGT_DEV_LD;

      $devices{$SRC_DEV_LD}{'oldest_state'} = $state;

    }

    else

    {

      #we haven't seen this SRC LD before, so we can assume that the TGT we see is the 'newest'.

      $devices{$SRC_DEV_LD}{'newest'} = $TGT_DEV_LD;

      #populate a list, 'all' which has all the devices in this 'set' in chronological order.

      #Not used in this script, but will let you do things like figure out

      #which snaps were taken at the same time, for doing a recovery of multiple LUNs.

               push ( @{ $devices{$SRC_DEV_LD}{'all'} }, $TGT_DEV_LD );

      #we also store this device as 'oldest' because if there's only one, it's both.

      $devices{$SRC_DEV_LD}{'oldest'} = $TGT_DEV_LD;

      $devices{$SRC_DEV_LD}{'oldest_state'} = $state;

    }

}

my $output = `$symcli_path/symsnap -g $device_group query -rdf -multi -output xml`;

#we set up this twig to process any occurance of XML tag 'Session' in the subroutine 'session_twig_parser'.

my $twig = new XML::Twig (

             twig_handlers => { 'Session' => \&session_twig_parser }

          );

$twig -> parse ( $output );

June 21st, 2011 07:00

HI,

Would appreciate if you can share with me the scripts that you have created.

Thank you.

No Events found!

Top