Hello, just joined the group looking for some help with Perl. I used to have
an NT box running Perl from Active State, it died in a most gruesome way.
Now I have a Novell 5.1 Server. Trying to reconfigure some of the scripts to
run in the Novell environment. 

On NT I had a script that ran on the hour and checked a specified directory
for data that was modified in the last hour and made copies of that data to
another directory, basically hourly backups. I kept a couple of weeks work
of the hourly usually. It saved me from going to the tape backups a lot
except for really old stuff. 

Obviously NT and Novell are two totally different environments, for one the
Novell being a nix uses "cp" instead of "copy". I've added copy as an alias
to cp so copy works now, but I can't seem to figure out how to type in the
paths to the directories I want to backup. 

Appreciate if anyone could help me figure out how to edit this script to be
Novell friendly. I am a complete and total newbie to Perl.

here is the old NT version of the script, which backed up the G drive to the
I:\backups directory
====================================================
#!/usr/local/bin/perl
use File::stat;
use File::Copy;
use File::Path;
#use File::Basename;

$now = time;

($SEC, $MIN, $HOUR, $MDAY, $MON, $YEAR, $WDAY,
        $YDAY, $ISDAYLITE)= localtime();

$DAY = sprintf("%02d-%02d-%02d", ++$MON, $MDAY, 1900+$YEAR);
$CURR_HOUR = sprintf("%02d", $HOUR);

&traverse('g:');

sub traverse {
    local($dir) = shift;
    local($path);
    unless (opendir(DIR, $dir)) {
        warn "Can't open $dir\n";
        closedir(DIR);
        return;
    }
    foreach (readdir(DIR)) {
        next if $_ eq '.' || $_ eq '..' ;
        $path = "$dir/$_";
        if (-d $path) {         # a directory
            &traverse($path);
        } elsif (-f _) {        # a plain file

        # print "$path\n";      # Print full path to display

          $date_string = (stat($path)->mtime);
                if ($now - $date_string < 3600) {       # is file modified
in the last hour ?
                $dest =$dir;
                $dest =~ s/g:/i:\/Backups\/$DAY\/$CURR_HOUR\/Gdrive/g;  
                $dest1 = "$dest/$_";
                # print "Backing up $path TO Hourly Backup Drive...\n";
                mkpath ("$dest");
                copy $path, $dest1;
                }
        }
    }
    closedir(DIR);
}

Chris Louden
Engineering Automation Support
Bechtel Nevada / D.O.E.
702-295-2336 -phone
702-794-1968 -pager

click on the link below to send a text message to my pager:
http://paging.nv.doe.gov/gw.wwwMsgLookup?form_type=SPFP&pin_num=7027941968

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to