Showing posts with label policy. Show all posts
Showing posts with label policy. Show all posts

Tuesday, April 7, 2009

Duplicating And Modifying NetBackup Policies, Schedules And Client Via Command Line On Linux And Unix

Hey There,

SPOILER ALERT: THE BULLET POINTS IN THIS POST ARE IN ALL CAPS. I'M SORRY FOR SHOUTING. I HAVE NO SENSE OF HOW OBNOXIOUSLY LOUD I AM!

Actually tomorrow's post has turned into today's and I'm going to do today's tomorrow. I don't know why I felt compelled to write that. I guess I just don't want you to lose track of time like I do ;)

Today we're going to check out a way to copy (and modify) an existing host's NetBackup policies, clients and schedules to a new host, and then modify those policies, clients and schedules (just slightly) to suit the new host (you can't backup to a hostname that isn't the name of the host you want to back up. ...if you want to backup your the new host, that is ;)

The beauty of it is that it can all be done from the command line. No more UI GUI for you :)

And now, in one of my driest pieces to date, a step by step guide on how to perform the process I just described above (If you're interested in staying away from the GUI, check out our old post on our NetBackup command line activity monitor)

1. GET YOUR POLICIES AND SCHEDULES FROM THE KNOWN-GOOD HOST YOU WANT TO EMULATE/REPLICATE (orig_host will be the known-good host and new_host will be the host you want to be just about the same. Also, we're assuming you've installed the base product. This walk-through is focused only on policies, policy schedules and policy clients).

orig_host # ls /usr/openv/netbackup/db/class (you may have more than this - generally there's one directory per policy. Each directory includes the schedules for the policy the directory name indicates):

HOST_BACKUP HOST_OS_BACKUP HOST_CATALOG


You may want to copy off the old policy and schedule output, just so you can compare it with your new host setup later and make sure you didn't forget to change any instances of an old hostname to your new hostname

orig_host # /usr/openv/netbackup/bin/admincmd/bppllist -allpolicies -U >/var/tmp/policies.txt


Then just tar that all up:

orig_host # tar cpf /var/tmp/policies_and_schedules.tar /usr/openv/netbackup/db/class /var/tmp/policies.txt


2. VERIFY THAT EITHER NO "class" DIRECTORY EXISTS ON YOUR NEW HOST, THE EXISTING "class" DIRECTORY IS EMPTY OR THAT IT JUST CONTAINS THE STANDARD TEST GARBAGE YOUR SETUP MAY COME WITH - DELETE IT OR UNTAR OVER IT IF YOU WANT TO (USER DISCRETION ADVISED!) - THIS MAY NOT BE A BIG DEAL SINCE YOU PROBABLY HAVE NO SCHEDULES OR POLICIES ON YOUR NEW HOST ANYWAY.

new_host # ls /usr/openv/netbackup/db
/usr/openv/netbackup/db: No such file or directory
new_host # ls /usr/openv/netbackp/db/class
/usr/openv/netbackp/db/class: No such file or directory
new_host # ls /usr/openv/netbackp/db
/usr/openv/netbackp/db: No such file or directory


3. AFTER SCP'ING/COPYING THE TAR FILE FROM YOUR KNOWN GOOD HOST, UNTAR IT ON THE NEW HOST AND LIST ALL POLICIES TO DOUBLE VERIFY - THE HOST NAMES WILL BE WRONG (FOR YOUR NEW HOST) SO THE DIFF WON'T BE TOO DIFFERENT!

new_host # tar xpf /var/tmp/policies_and_schedules.tar
new_host # /usr/openv/netbackup/bin/admincmd/bppllist -allpolicies -U >/var/tmp/policies_new.txt
diff /var/tmp/policies.txt /var/tmp/policies_new.txt


4. CHECK THAT ALL THE POLICIES ARE THERE IN YOUR policies_new.txt FILE (YOU CAN LOOK IN BPADM, TOO). ALL HOSTNAMES AND TAPE RESIDENCE NAMES WILL STILL BE WRONG (ANYTHING THAT CONTAINS A HOSTNAME, ANYWAY)

new_host # /usr/openv/netbackup/bin/admincmd/bppllist -M new_host
HOST_BACKUP
HOST_OS_BACKUP
HOST_CATALOG


5. DETERMINE YOUR TAPE RESIDENCE (TLD NAME) ON THE NEW HOST (FIRST ENTRY IN OUTPUT BELOW)

new_host # /usr/openv/netbackup/bin/admincmd/bpstulist
new_host-hcart3-robot-tld-o 2 new_host 8 0 20 2 0 "*NULL*" 0 1 1048576 *NULL* 0 1 0 0 0 0 *NULL* new_host


"new_host-hcart3-robot-tld-o" is the residence name

6. ASSUMING ALL POLICIES LISTED ABOVE ARE GOOD, YOU WON'T HAVE TO MODIFY THIS LINE TO REMOVE AND/OR UPDATE THE RESIDENCE FOR ALL POLICIES (OF COURSE, THEY PROBABLY AREN'T SINCE THIS POST WAS WRITTEN FOR THE GENERAL PUBLIC ;)

new_host # while read line;do /usr/openv/netbackup/bin/admincmd/bpplinfo $line -modify -residence new_host-hcart3-robot-tld-o;done <<< "`/usr/openv/netbackup/bin/admincmd/bppllist -M new_host`"


7. LIST OUT ALL THE SCHEDULES NOW - NOTE THAT YOU MAY NOT WANT TO MODIFY YOUR CATALOG POLICY AND THAT SOME POLICIES HAVE MORE THAN ONE CLIENT (This may vary from setup to setup, so it's important to check!)

NOTE ALSO THAT, SINCE YOU'RE NOT CHANGING YOUR SCHEDULES, ALL YOU NEED TO DO TO MODIFY THEM IS TO CHANGE THE CLIENTS ASSOCIATED WITH THEM, WHICH GETS DONE IN THE FOLLOWING STEPS, AS WELL :)

new_host # while read line;do echo "POLICY $line";/usr/openv/netbackup/bin/admincmd/bpplclients $line;done <<< "`/usr/openv/netbackup/bin/admincmd/bppllist -M new_host`"
POLICY HOST_BACKUP
Hardware OS Client
--------------- --------------- --------------
Solaris Solaris10 orig_host
POLICY HOST_OS_BACKUP
Hardware OS Client
--------------- --------------- --------------
Solaris Solaris10 orig_host
Solaris Solaris10 orig_host2
POLICY HOST_CATALOG
Hardware OS Client
--------------- --------------- --------------
Solaris Solaris8 orig_host


8. WITH THE SAME ASSUMPTIONS AS ABOVE, USE THIS TO CHANGE CLIENTS FOR YOUR POLICIES - CHOPPING OFF LAST POLICY AND MODIFIYING CLIENTS BY TAKING INPUT FROM LIST, MODIFYING AND THEN RUNNING "ADD NEW" AND "DELETE OLD" IN A LOOP (The simple sed expression to change the host name can be as specific as you like)

A. DO A "PROOF OF CONCEPT" RUN FIRST

while read line;do count=3;for x in $(/usr/openv/netbackup/bin/admincmd/bpplclients $line|awk '{print $3}'|grep db|/usr/bin/sed 's/orig_/new_/g'|xargs echo);do oldhwos=$(/usr/openv/netbackup/bin/admincmd/bpplclients $line|sed -n ${count}p|awk '{print $1,$2}');let count=$count+1;echo "POC TEST $line /usr/openv/netbackup/bin/admincmd/bpplclients $line -add $x $oldhwos";done;done <<< "`/usr/openv/netbackup/bin/admincmd/bppllist -M new_host|egrep -iv 'vault|catalog'`"
POC TEST HOST_BACKUP /usr/openv/netbackup/bin/admincmd/bpplclients HOST_BACKUP -add new_host Solaris Solaris10
POC TEST HOST_OS_BACKUP /usr/openv/netbackup/bin/admincmd/bpplclients HOST_OS_BACKUP -add new_host Solaris Solaris10
POC TEST HOST_OS_BACKUP /usr/openv/netbackup/bin/admincmd/bpplclients HOST_OS_BACKUP -add new_host2 Solaris Solaris10


B. THEN - IF ALL IS WELL - DO IT FOR REAL

while read line;do count=3;for x in $(/usr/openv/netbackup/bin/admincmd/bpplclients $line|awk '{print $3}'|grep db|/usr/bin/sed 's/orig_/new_/g'|xargs echo);do oldhwos=$(/usr/openv/netbackup/bin/admincmd/bpplclients $line|sed -n ${count}p|awk '{print $1,$2}');let count=$count+1;echo "Running /usr/openv/netbackup/bin/admincmd/bpplclients $line -add $x $oldhwos";/usr/openv/netbackup/bin/admincmd/bpplclients $line -add $x $oldhwos;done;done <<< "`/usr/openv/netbackup/bin/admincmd/bppllist -M new_host|egrep -iv 'vault|catalog'`"
Running /usr/openv/netbackup/bin/admincmd/bpplclients HOST_BACKUP -add new_host Solaris Solaris10
Running /usr/openv/netbackup/bin/admincmd/bpplclients HOST_OS_BACKUP -add new_host Solaris Solaris10
Running /usr/openv/netbackup/bin/admincmd/bpplclients HOST_OS_BACKUP -add new_host Solaris Solaris10


C. CHECK TO MAKE SURE THE NEW CLIENTS ARE ADDED

while read line;do /usr/openv/netbackup/bin/admincmd/bpplclients $line ;done <<< "`/usr/openv/netbackup/bin/admincmd/bppllist -M new_host`"
Hardware OS Client
--------------- --------------- --------------
Solaris Solaris10 orig_host
Solaris Solaris10 new_host
Hardware OS Client
--------------- --------------- --------------
Solaris Solaris10 orig_host
Solaris Solaris10 orig_host1
Solaris Solaris10 new_host
Solaris Solaris10 new_host1
Hardware OS Client
--------------- --------------- --------------
Solaris Solaris8 orig_host
Solaris Solaris8 new_host


D. NOW SOME POC TO MAKE SURE THE DELETE OF THE OLD HOSTS WORKS OKAY

while read line;do for x in $(/usr/openv/netbackup/bin/admincmd/bpplclients $line|awk '{print $3}'|grep orig_|xargs echo);do echo "POC TEST $line /usr/openv/netbackup/bin/admincmd/bpplclients $line -delete $x";done;done <<< "`/usr/openv/netbackup/bin/admincmd/bppllist -M new_host|egrep -iv 'vault|catalog'`"
POC TEST HOST_BACKUP /usr/openv/netbackup/bin/admincmd/bpplclients HOST_BACKUP -delete orig_host
POC TEST HOST_OS_BACKUP /usr/openv/netbackup/bin/admincmd/bpplclients HOST_OS_BACKUP -delete orig_host
POC TEST HOST_OS_BACKUP /usr/openv/netbackup/bin/admincmd/bpplclients HOST_OS_BACKUP -delete orig_host1


E. THEN REMOVE THEM FOR REAL

while read line;do for x in $(/usr/openv/netbackup/bin/admincmd/bpplclients $line|awk '{print $3}'|grep orig_|xargs echo);do echo "Running /usr/openv/netbackup/bin/admincmd/bpplclients $line -delete $x";/usr/openv/netbackup/bin/admincmd/bpplclients $line -delete $x;done;done <<< "`/usr/openv/netbackup/bin/admincmd/bppllist -M new_host|egrep -iv 'vault|catalog'`"
Running /usr/openv/netbackup/bin/admincmd/bpplclients HOST_BACKUP -delete orig_host
Running /usr/openv/netbackup/bin/admincmd/bpplclients HOST_OS_BACKUP -delete orig_host
Running /usr/openv/netbackup/bin/admincmd/bpplclients HOST_OS_BACKUP -delete orig_host1


F. THEN CHECK AGAIN

while read line;do /usr/openv/netbackup/bin/admincmd/bpplclients $line ;done <<< "`/usr/openv/netbackup/bin/admincmd/bppllist -M new_host`"
Hardware OS Client
--------------- --------------- --------------
Solaris Solaris10 new_host
Hardware OS Client
--------------- --------------- --------------
Solaris Solaris10 new_host
Solaris Solaris10 new_host1
Hardware OS Client
--------------- --------------- --------------
Solaris Solaris8 orig_host


9. NOW THAT YOU'VE GOT THE POLICIES, SCHEDULES AND CLIENTS MOVED OVER, MAKE SURE THAT YOUR CATALOG JOB EXISTS (IF YOU USE ONE)

new_host # /usr/openv/netbackup/bin/admincmd/bppllist HOST_CATALOG
CLASS HOST_CATALOG *NULL* 0 650000 0 *NULL*
NAMES
INFO 35 1 0 0 *NULL* 0 0 1 1 0 1 2 0 0 0 0 0 0 1236208342 EA91EDF01DD111B2AB1900144FEAC8FE 1 0 0 0 0 0 0 0 2 0 0 0 0 0 6
KEY *NULL*
BCMD *NULL*
RCMD *NULL*
RES new_host-hcart3-robot-tld-o *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL*
POOL CATALOGPOOL NetBackup NetBackup NetBackup NetBackup NetBackup NetBackup NetBackup NetBackup NetBackup
FOE 0 0 0 0 0 0 0 0 0 0
SHAREGROUP *ANY*
DATACLASSIFICATION *NULL*
CLIENT new_host Solaris Solaris8 0 0 0 0 *NULL*
INCLUDE CATALOG_DRIVEN_BACKUP


10. NOW JUST DEACTIVE ANY POLICIES THAT ARE ACTIVE AND SHOULDN'T BE AND ACTIVATE ANY POLICIES THAT SHOULD BE ACTIVE BUT AREN'T!

All set!

CHEERS! ;)

, Mike




Discover the Free Ebook that shows you how to make 100% commissions on ClickBank!



Please note that this blog accepts comments via email only. See our Mission And Policy Statement for further details.

Friday, July 18, 2008

General Policy And Mission Statements For "The Linux And Unix Menagerie" Web Log

Mission Statement - Rev 1.0:

The Linux and Unix Menagerie WebLog (hereafter referred to as the "blog") has a very simple mission statement, that is open to change and revision if, for any reason, the intent or direction of the blog's content radically changes. As this Mission Statement may change in the future (although we doubt that it will to a great degree), please revisit The Linux and Unix Menagerie blog to ensure that you are reading the most up to date revision.

Our blog's mission is to provide, hopefully, helpful advice on a wide variety of Unix/Linux computing-related topics to Linux and Unix users and administrators of varying skill levels. We do not answer to, nor do we specifically recommend, any particular distribution of Linux and/or Unix and try to be as unbiased as possible (although we will name distro's specifically when it is germane to the subject matter). This blog's content is also not restricted to the Unix and/or Linux OS. Topics may include many things related to Unix/Linux, including, but not limited to, hardware used to run the OS and maintenance thereof, programming/scripting within the OS, applications that can be used on the OS and technical, or OS, opinion in general. This blog covers a very wide range of topics and the preceding list should be taken as a rough outline (as almost every post has "something" to do with Linux or Unix) and not a concrete limitation to the type of content available to anyone who wishes to read it.

It is our hope that this blog (each and/or any one of its posts) may provide someone, somewhere with a little help, assistance or nudge in the right direction so that they can enjoy the Linux and Unix experience more fully or feel more comfortable with using Linux or Unix. We love it, and hope to spread that excitement and enthusiasm to you.

We also, along the same lines, try to present our material in a manner which is most accessible to all levels of user or administrator. Much of this blog consists of prose and dialogue and much of it consists of examples which cannot be modified to suit the author's taste (For Example: We might write an entire page about why we think booting to cdrom from the ok> prompt on Solaris is great, but we would leave the actual command ("boot cdrom") as is. We can't change that simple command to suit our writing style)

Our hope is that this blog provides an even balance of explanation and introduction to the many facets of Unix/Linux system administration and computing in as entertaining and creative a way as possible.

Statement of Policies - Rev 1.0:

1. No comment policy: While we do not accept comments directly on this blog, this does not mean that we don't appreciate them and/or encourage them. For this reason, a static email link is present on every page of the blog at the top right hand corner (below the header). The blog provides a free service and, in an attempt to do so, spends as much time as possible to ensure that each post is as accurate as it can be. We do not eschew the reader's thoughts or idea's at all (note the email link). We think comments are great, and welcome (and respond to) them in various alternate venues that carry this blog's contents, as often, and as consistently, as is reasonably possible. We do not encourage commenting for commenting's sake and do not write our material in anticipation of comments, as this would seriously skew the "everyman" flavour we try to bring to the blog. Again, we do appreciate all comments, but make no guarantees that they will be answered (although we've yet to not return an email). Our no comment policy also stands, as our hosting provider (Google) crawls our site almost every day and we do not wish to risk losing the blog because of site spamming, pornographic posting, vulgarity, obscenity or any other material Google does not deem appropriate for a site that is not considered "adult." Keep in mind that Google crawls even those comments that are waiting in moderation and we have no control over the "robots.txt" file and can only set a Meta Tag to FOLLOW or NOFOLLOW (the latter almost guaranteeing that we don't get indexed well in Google's search engine). This may seem like blatant cow-towing to Google, and it is. Since our blog needs to first be found before it even be considered for comment, we do what we can to keep them happy and abide by the rules of their TOS. They basically "own" the internet search market. We make no apologies for complying with their standards.

2. No commercial Guarantee policy: All of the material posted on this blog is posted as free advice and we make no commercial guarantee that anything you read here will be absolutely relevant to your situation, need or desire. Any scripts posted on this site, although tested to run on various OS's before posting, should be double checked by the reader before being used for any reason at all on personal, or work, computers. All advice and help, although posted in good faith, may or may not be suitable for your purposes. We make no guarantee, and assume no responsibility, for any damage caused by any idea, method or script/code that you choose to implement on your own Unix/Linux hardware, OS and/or networks.

3. No Charge policy: Everything posted in this blog is posted free-of-charge, which (we believe) is the very nature of blogging: Free exchange, or posting, of information with no strings attached. You will never be asked, or solicited in any way, to fill out forms, vote in polls, click on links or do anything except open your browser and make your way to our site in order to have full access to the information presented in each and every post, except in the odd situation that a post gets pulled and is no longer available for public consumption.

4. Creative Commons Licensing policy: We license this blog under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 license. You can follow the link for the legal nitty-gritty, but it, in effect, states that all original material posted on this blog belongs to the blog author(s) and can only be used for non-commercial purposes, and may be modified, or word-for-word redistributed, as long as full attribution is given to the original author and is, likewise, shared under an equal license. We feel this is a fair licensing method and provides us with virtually no protection or reward unless (if by some miracle) content from this site is used to create a "for profit" product. We would, then, be entitled to a cut, which would be a raise of however much that cut is, from our current salary received for creating and maintaining this blog, which is still hovering at zero dollars and zero cents per hour.

5. Email comment policy: We strongly encourage any reader with a desire to help improve this blog, or point out an obvious imperfection, to email us with any suggestions he or she might have that will help improve the quality of the blog and make it a better source for others to come and find help. We cannot guarantee any specific response time (again this blog is being maintained for no fee at the expense of the author(s)' free time), but make every attempt to respond within a 24 hour period whenever possible. This policy is closely related with our "no comment" policy as Google does not crawl our email accounts and reception of materials in violation of Google's TOS, in this manner, will not affect the blog, or its existence, in any way. We reserve the right to completely ignore (to the point of not responding and/or blocking) any threatening emails, harassment or other objectionable materials or SPAM that is sent to our blog's email address.

In summation: This is version 1.0 of both our Mission Statement and Statement of Policies. They may be revised at any time, and the reason for revision may be because of a suggestion made by one of our readers. If you wish to suggest an addition, subtraction, enhancement or refinement of any of the policies listed above, please email us via the "Send me a comment" link at the top right of every page of our blog.

Thank you,

The Linux and Unix Menagerie

Friday, December 21, 2007

NetBackup Policy Reporting Script

This is a follow-up to an earlier post regarding NetBackup where we dealt with using scripting to monitor daily NetBackup activity (actually, the time frame of the reporting was open if you wanted to change it).

In this little scriptlet, we deal with reporting on NetBackup Policies. Since this is widely variable (You name your own policies, after all), I made that part of the pattern-matching involved a variable ;). The script parses the bppllist command output using the standard -U option, which is formatted for easier reading and makes for easier line matching. Another variation on this, if you prefer to report on Types rather than Names is running bppllist with the -L option. This will give you output such as:

Policy Type: MS-Exchange-Server

and

Type: FULL SExchange

These options are addressed by including a variables section at the top of the script so that you can customize it in that way rather than deal with working your way back up through script options on top of bppllist options. In short, it's only a little less confusing, but looks a lot better. My feeling is that, in some instances it's better to have 3 slightly differently named versions of the same script that you run when you need to, rather than trying to remember 3 different ways to invoke a script that would require you to remember various patterns you needed to match.

Of course, this is presented for your assistance and, hopefully, convenience. Feel free to modify it to suit your particular needs and style.

Have a great weekend!


Creative Commons License


This work is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License

#!/usr/bin/perl

#
# list_bp_schedules
# 2007 - Mike Golvach - eggi@comcast.net
#
# Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
#

##############################################
# Variables that should probably be edited
$names_or_types = "1"; # 0 = Types - 1 = Names
$policy_name_or_type = "MY_POLICY"; # This is treated as a regexp!
##############################################

if ( $names_or_types ) {
@bp = `/usr/openv/netbackup/bin/admincmd/bppllist -allpolicies -U`;
} else {
@bp = `/usr/openv/netbackup/bin/admincmd/bppllist -allpolicies -L`;
}

$date = `date +%m%d%y`;
open (OUTPUT, ">>Schedules.$date");
select(OUTPUT);
foreach $line (@bp) {
if ( ! $daily ) {
if ( $names_or_types ) {
print "$line\n" if ( $line =~ /Policy Name/ || $line =~ /Schedule/ );
} else {
print "$line\n" if ( $line =~ /Policy Type/ || $line =~ /Schedule/ );
}
if ( $line =~ /$policy_name_or_type/ ) {
$daily = 1;
}
} elsif ( $daily ) {
if ( $line =~ /\w/ ) {
print "$line\n";
} else {
$daily = 0;
next;
}
}
}


, Mike