#!/usr/bin/perl # # 2001 (c) 1U Ring Inc, All Rights Reserved # # - You may do anything you like with it...except sell the script # # Latest Version # -------------- # http://www.Linux-Backup.net/scripts/Backup_www.pl # # # Incremental Backup the System # ============================= # == # == see Backup.pl # == # - make sure the /Backup/$Host directory exists BEFORE running this script # - HTML display subroutines for Backup.pl -view # # # To Crete new backup.html # ------------------------ # cd /usr/lib/perl5 ; ln -s ....Backup_www.pl . # cd Backup ; Backup.pl -test > backup.html # use ^D to skip # # cd /home/httpd/cgi-bin ; ./Backup.pl -www > ../html/backup.html # # # 28-Jun-99 amo Separate web-based viewer from backup/mirror section # 27-Feb-02 amo Clean up # # ------------------------------------------------------------------------------------ # # Global Variables defined in Proc_Form # my ( $Content ) = 0; # # local ( $Backup_Mach ) = "All"; local ( $Backup_Mon ) = ""; local ( $Backup_Day ) = ""; # # # Binaries # -------- #ocal ( $FIND ) = "/usr/bin/find"; # # # ---------------------------------------------- # Run this Backup GUI on "BackupServer.foo.com" # ---------------------------------------------- # # - these variables are defined in Backup.pl # local ( $BackupServer ) = "Backup.$Domain"; # local ( $Backup ) = "/Raid_Backup"; # large backup disk space on Backup.foo.com local ( $BackupDir ) = "$Backup/Backup.$Host"; # # # # ------------------------------------------------------------------ # sub Backup_View { my ( $TOP ) = @_[0]; # /Raid_Backup my ( $Host ) = @_[1]; # Backup.Foo.com # # my ( @Day ) = ""; my ( $id ) = 0; # # $Content = printf "Content-type: text/html\n\n" if ( $Content == 0 ); # # printf "\n"; printf "\n"; printf "\n"; # printf "\n"; printf "\n"; printf " Backup Logs \n"; printf "\n"; printf "\n"; printf "

\n"; printf "

Backup Logs

\n"; printf "

\n"; # # ###== printf "\n"; ###== # ###== printf "\n"; ###== printf "\n"; ###== # ###== printf "\n"; ###== # ###== printf "\n"; ###== # ###== printf "\n"; ###== # ###== printf "\n"; ###== # ###== printf "\n"; ###== # ###== printf "\n"; ###== printf "\n"; ###== printf "
\n"; ###== printf " Backup Configuration:
    \n"; ###== # ###== printf "
\n"; ###== printf " Daily Incremental
\n"; ###== printf " Weekly Incremental
\n"; ###== printf " Montly Incremental
\n"; ###== printf "
\n"; ###== printf "
\n"; ###== printf "
\n"; ###== printf " Daily Full
\n"; ###== printf " Weekly Full
\n"; ###== printf " Monthly Full
\n"; ###== printf "
\n"; ###== printf "
\n"; ###== printf "
\n"; ###== printf " Daily Tape
\n"; ###== printf " Weekly Tape
\n"; ###== printf " Monthly Tape
\n"; ###== printf "
\n"; # # # # # Search Archives for Files # ========================== # printf "\n"; printf "\n"; printf "\n"; printf "\n"; # printf "\n"; printf "\n"; printf "
\n"; printf "

\n"; printf "\n"; printf "
\n"; printf "
\n"; printf "
\n"; # # # printf "Top=$TOP..Host=$Host...Dir=$BackupDir..Mon[$#Mon]..
\n"; # printf "..whoami=%s..groups=%s..\n", `whoami`, `groups` ; # # End search box # printf "\n"; printf "\n"; printf "\n"; # List of Machines # # # my ( $back, $host ) = ""; my ( $BackupDir ) = ""; # # # Check Backups for this Selected Machine # ======================================== # if ( $Back_Mach ne "" ) { # # ( $back, $host ) = split ( /\./, $Back_Mach ); # ( $BackupDir ) = "$TOP/Backup.$host/$host"; # # # # List of Monthly Backup Directories of the Machine to check # ---------------------------------- # my ( @Mon ) = `cd /$BackupDir ; find . -type d -print `; # # printf "\n"; # end months # } # selected Machine # # # ---------------- # Selected Month # ---------------- # if ( $Back_Mon ne "" ) { # # Daily Backup Files # ------------------ # printf "\n"; # end days # } # daily backups # # # # Read Daily Backup Log # --------------------- # if ( $Back_Day ne "" ) { # printf "\n"; # end daily log file # printf "
\n"; printf "

\n"; # # End Search Box # # # List of Backed Up Machines # ---------------------------------- # my ( @Mach ) = `cd $TOP ; find . -type d -maxdepth 1 -print | grep -v lost `; # my ( %SortMach ) = ""; # # ------------------------------------------------------- # $id = 0; while ( $id <= $#Mach ) { chomp ( $str = $Mach[$id] ); # # skip over "." directories # if ( $str ne "." ) { # $str =~ s/^.\///; # $SortMach{ "$str" } = "$str" ;a # value not used # } # skip "." # $id += 1; # } # machines # # # List of Sorted machines # ------------------------- # foreach $mach ( sort keys %SortMach ) { # if ( $mach eq $Back_Mach ) { printf "  $mach

\n"; } else { printf "  $mach

\n"; } } # sorted # printf "
\n"; printf "
\n"; printf "

\n"; # printf "

$Back_Mach


\n"; # $id = 0; while ( $id <= $#Mon ) { # chomp ( $str = $Mon[$id] ); # # skip over dirs with . and .. # if ( $str ne "." ) { # $str =~ s/^.\///; # if ( $str eq $Back_Mon ) { printf " $str

\n"; } else { printf " $str

\n"; } } # mon # $id += 1; # } # months # printf "
\n"; printf "
\n"; printf "

\n"; # # printf "

$Back_Mon


\n"; # # @Day = `cd /$BackupDir/$Back_Mon ; find . -name \\\*.log `; # # ------------------------------------------------------- # $id = 0; while ( $id <= $#Day ) { chomp ( $str = $Day[$id] ); $str =~ s/^.\///; # if ( $str eq $Back_Day ) { printf " $str
\n"; } else { printf " $str
\n"; } # $id += 1; } # days # # ---------------------------------------------------- # printf "
\n"; printf "
\n"; printf "\n"; # printf "
\n"; printf "
\n"; # # ---------------------------------------------------- # # Contents of the log file # @DayLog = `cd $BackupDir/$Back_Mon ; cat $Back_Day `; # printf "

%d Entries in $Back_Day


\n", $#DayLog + 1; # # $id = 0; printf "\n"; # while ( $id <= $#DayLog ) { chomp ( $str = $DayLog[$id] ); $str =~ s/^.\///; # @dat = split ( /\s+/, $str ); # printf "\n"; # $jd = 0; while ( $jd <= $#dat ) { printf "\n"; $jd += 1; } printf "\n"; # $id += 1; } # days # printf "
$id: $dat[$jd]
\n"; # data # printf "
\n"; # data # printf "
\n"; printf "
\n"; # backup logfiles printf "\n"; # } # Daily Log # # # ------------------------------------- # Search for Stuff Across ALL machines # ------------------------------------- # if ( $Back_Srch ne "" ) { # # Search for filenames in Backup logs # my ( @Srch ) = ""; # # Default Search # my ( $Srch_Dir ) = "$TOP"; my ( $Srch_Log ) = "*/*/*/*.log"; # # # Search only this server # ----------------------- # if ( $Back_Mach ne "" ) { ( $back, $host ) = split ( /\./, $Back_Mach ); # $Srch_Dir = "$TOP/Backup.$host/$host" ; $Srch_Log = "*/*.log"; } # # Search only this month # ------------------------ # if ( $Back_Mon ne "" ) { $Srch_Dir = "$TOP/Backup.$host/$host/$Back_Mon" ; $Srch_Log = "*.log"; } # # @Srch = `cd /$Srch_Dir ; /bin/grep -i "$Back_Srch" $Srch_Log `; # # # # Search the Backup Log files # --------------------------- # printf "\n"; # if ( $#Srch >= 0 ) { # printf "
Found $#Srch Matches for $Back_Srch..
[ $Srch_Dir ]
\n"; # printf "\n"; # $id = 0; while ( $id <= $#Srch ) { # # 02.32.log:-rw-r--r-- root/root 2191 2002-01-04 01:33:52 etc/passwd # $srch = $Srch[$id]; $srch =~ s/:/ /; # just change the first one # ( $yr_mon, @str ) = split ( /\s+/, $srch ); # printf "\n"; # $jd = 0; while ( $jd <= $#str ) { printf "\n", $str[$jd]; $jd += 1; } printf "\n"; # $id += 1; # } # while # printf "
$id $yr_mon %s
\n"; # end search results # } else { # printf "
No matches Found for '$Back_Srch'....
\n"; # } # } # end of search # # # printf "\n"; printf "\n"; # printf "\n"; printf "\n"; # # # printf "\n"; printf "umount $TOP\n"; printf "\n"; ` umount $TOP 2>&1 /dev/null`; # exit ( 0 ); # } # Backup_View # # # # Process the Web Page Forms # -------------------------- # sub Proc_Form { # # local ( $GN_ARG ) = $ENV{PATH_INFO}; # Get the argument from the URL # local ( $GN_QUERY ) = $ENV{QUERY_STRING}; # my ( $postinput ) = ; # # For Backup.pl, it uses GET method # --------------------------------- # my ( $getinput ) = $ENV{QUERY_STRING}; # my ( @p_v ) = (); # # $Content = printf "Content-type: text/html\n\n" if ( $Content == 0 ); # printf "..post=$ENV{REQUEST_METHOD}..
GN=$GN_QUERY..
post=$postinput
\n"; # # if ( $ENV{REQUEST_METHOD} eq "POST") { # # It's the POST method, so print content length and coded input from # STDIN. Then decode it and print again. # $GN_QUERY =~ s/\+/ /g; # Change +'s to spaces # print "Posted input content-length = $len..GN=$GN_QUERY..
\n"; # print "Undecoded posted input:
..$postinput

\n\n"; # $postinput =~ s/&/&
\n/g; $postinput =~ s/\+/ /g; $postinput =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig; # # } # post # # # $Content = printf "Content-type: text/html\n\n" if ( $Content == 0 ); # print "postinput:..$postinput
\n"; # print "getinput:..$getinput
\n"; # $str = "$postinput" . "&" . "$getinput"; # concatenate together # ( @p_v ) = split ( /&/, $str ); # while ( $id <= $#p_v ) { # ( $p, $v ) = split ( /=/, $p_v[$id] ); # # $Back_Srch = "$v" if ( $p eq "Srch" ); # from web input box # $Back_Mach = $v if ( $p eq "BackMach" ); $Back_Mon = $v if ( $p eq "BackMon" ); $Back_Day = $v if ( $p eq "BackDay" ); # # printf "..p_v[$id]=$p..v=$v..
\n"; # $id += 1; # } # param_value pairs # # printf "..Srch=$Back_Srch..
\n"; # return ( @p_v ); # } # Proc_Form # # 1; # return true for require statment # # end of file