from:  <[EMAIL PROTECTED]> (Pete Fiorese)
   
     I'm looking for a way to determine if I've missed some volumes when
   creating my backup volume sets.  Is there a way to generate a list of
   volumes which have not been dumped in the last month?  I'd like to avoid
   writing the shell script which does a 'backup volinfo' on every volume.
   Thanks for any pointers.

Well, it's not a pointer but what I just wrote last week was a perl 
script to do a "smarter" vos backupsys. It will only create a new 
backup if the read-write volume is newer than the backup. 

Thus... it took our site's vos backupsys from 10 hours to 2 hours.

There are 3 options to it...
        -p (to select the prefix your are looking for)
        -d (to turn on debug mode)
        -D (to turn on DEBUG mode (lots of output)

And it's fairly straight forward code, but you have to set the $DOMAIN to 
your domain otherwise, the code to check for your token won't work....

Scott

PS> Does anyone know a good place to find/hire AFS aware admins? I don't 
want to pollute the list, but apart from here, I have no good avenues.

Here's the code...

#########BEGIN CODE##########
#!/pkg/perl5/bin/perl
#
# THIS IS UNSUPPORTED SOFTWARE -- USE IT AT YOUR OWN RISK!!!  THE
# USER AGREES TO HOLD THE AUTHOR(S) and QUALCOMM INCORPORATED HARMLESS,
# AND INDEMNIFY THEM FROM ANY CLAIM OF LOSS OR DAMAGE RESULTING FROM
# THE USE OF OR INABILITY TO USE THIS SOFTWARE -- EVEN IF SUCH LOSS
# RESULTS FROM GROSS NEGLIGENCE ON THE PART OF THE AUTHOR(S). 

# load in required perl libraries.
require 'getopts.pl';
 
$DOMAIN="qualcomm.com";

&Getopts('p:Dd'); 
if ($opt_d) { $DEBUG = 1; }
if ($opt_D) { $BIG_DEBUG=1; $DEBUG = 1; }
if ($opt_p) { $prefix=$opt_p; }
 
if(!defined $BIG_DEBUG){
        # Check to see if we have a token....
        open(TOKENS, "/usr/afsws/bin/tokens |")|| die("Tokens not found!\n");
        while(<TOKENS>){
                $DEBUG && print("read in from tokens: $_\n");
                if(/\(AFS ID (\d+)\).*for afs\@$DOMAIN.com/) {
                        $DEBUG && print("found id $1\n");
                        open(PTS,"/usr/afsws/bin/pts examine $1|")|| die("Can't 
examine the token!\n");
                        while(<PTS>){
                                $DEBUG && print("read in from pts: $_\n");
                                if(/Name: (.*), id:/){
                                        $DEBUG && print("found name $1\n");
                                        $name_of_token = $1;
                                        if (%system_administrators){} else {
                                                open(MEMBERSHIP,"/usr/afsws/bin/pts 
membership system:administrators |") || die("can't vrfy membership!\n");
                                                while (<MEMBERSHIP>){ 
                                                        $DEBUG && print("read in from 
membershio: $_\n");
                                                        chop;
                                                        if(/^\s+(\S+)/){
                                                                $DEBUG && print("found 
member $1\n");
                                                                
$system_administrators{$1}="YES";
                                                        }
                                                }
                                                close (MEMBERSHIP);
                                        }
                                        if ($system_administrators{$name_of_token} eq  
"YES") {
                                                $DEBUG && print("found an admin token 
and it's $name_of_token\n"); 
                                                $admin_token_found=1; 
                                        }
                                }
                        }
                }
        }
        close(TOKENS);
        if (!defined $admin_token_found) {print("User doesn't have an admin 
token\n");exit;}
}
 
%months = 
('Jan',1,'Feb',2,'Mar',3,'Apr',4,'May',5,'Jun',6,'Jul',7,'Aug',8,'Sep',9,'Oct',10,'Nov',11,'Dec',12,);
 
open (VOS_LISTVLDB,"/usr/afsws/etc/vos listvldb |")||die("can't get volumes from 
vldb");
while(<VOS_LISTVLDB>){
        if (/^Total entries:/){ $BIG_DEBUG && print("skipping line $_"); next;}
        elsif(/^(\S+)/) { $BIG_DEBUG && print ("found a new volume named $1\n");
                $volume=$1; $volumes{$1}=$1;}
        if(/RWrite:\s+(\d+)\s+/){ $BIG_DEBUG && print ("found a RWrite volid for 
$volume = $1\n");
                $RWrite_id{$volume}=$1; }
        if(/ROnly:\s+(\d+)\s+/){ $BIG_DEBUG && print ("found a ROnly volid for $volume 
= $1\n");
                $ROnly_id{$volume}=$1; }
        if(/RClone:\s+(\d+)\s+/){ $BIG_DEBUG && print ("found a RClone volid for 
$volume = $1\n");
                $RClone_id{$volume}=$1; }
        if(/Backup:\s+(\d+)\s+/){ $BIG_DEBUG && print ("found a Backup volid for 
$volume = $1\n");
                $Backup_id{$volume}=$1; }
        if(/server\s+(\S+)\s+partition\s+(\S+)\s+RW/){ $BIG_DEBUG && print ("found a 
RW server for $volume = $1, and volume $2\n");
                $RW_server{$volume}=$1; $RW_partition{$volume}=$2; }
        if(/server\s+(\S+)\s+partition\s+(\S+)\s+RO/){ $BIG_DEBUG && print ("found a 
RO server for $volume = $1, and volume $2\n");
                $RO_server{$volume}=$1; $RO_partition{$volume}=$2; }
}
close(VOS_LISTVLDB);
 
foreach $volume (sort keys (%volumes)){
        $DEBUG && print("now doing $volume :");
        if (defined($prefix)){
                if ($volume =~ /^$prefix/){
                        $DEBUG && print(" matches $prefix :");
                } else {
                        $DEBUG && print(" does not match $prefix : Therefore 
skipping\n");
                        next;
                }
        }
        if ( defined $Backup_id{$volume} ) {
                open(VOS_EXAMINE,"/usr/afsws/etc/vos examine $volume|")||die("Can't 
examine $volume");
                while(<VOS_EXAMINE>){
                        if(/Last Update \S+ (\S+) (\d+) (\d+):(\d+):(\d+) (\d+)/){
                                
$rw_date{$volume}=sprintf("%d%02d%02d%02d%02d%02d",$6,$months{$1},$2,$3,$4,$5);
                                $BIG_DEBUG && print("found date $volume = 
$rw_date{$volume}\n");
                        }
                }
                close(VOS_EXAMINE);
                open(VOS_EXAMINE,"/usr/afsws/etc/vos examine 
$volume.backup|")||die("Can't examine $volume");
                while(<VOS_EXAMINE>){
                        if(/Last Update \S+ (\S+) (\d+) (\d+):(\d+):(\d+) (\d+)/){
                                
$bk_date{$volume}=sprintf("%d%02d%02d%02d%02d%02d",$6,$months{$1},$2,$3,$4,$5);
                                $BIG_DEBUG && print("found date $volume = 
$bk_date{$volume}\n");
                        }
                }
                close(VOS_EXAMINE);
                if ($bk_date{$volume} le $rw_date{$volume}) {
                        $DEBUG && print(" backup volume is old, will be backed up.\n");
                        $backup_list{$volume}=$volume;
                } else{
                        $DEBUG && print(" backup volume is up to date.\n");
                }
        } else { 
                $DEBUG && print(" no backup volume, will backed up \n");
                $backup_list{$volume}=$volume;
        }
}
 
foreach $volume (sort keys (%backup_list)){
        print("Backing up $volume\n");
        if( defined $DEBUG){
                print("/usr/afsws/etc/vos backup $volume -verbose\n");
        } else { 
                system("/usr/afsws/etc/vos backup $volume -verbose");
        }
}

###########END CODE##########

Reply via email to