#! /usr/bin/perl use warnings ; use strict ; ################################ # Creates Archives with WinRar # # lmm 123004 # ################################ my ($sec, $min, $hrs, $day, $month, $year) = (localtime)[0,1,2,3,4,5] ; my $YYYY = $year+1900 ; my $MM = $month+1 ; my $DD = $day ; my $HH = $hrs ; my $MN = $min ; my $SS = $sec ; my $date = "$YYYY-$MM-$DD" ; my $destdir = "\\\\gwnas\\reliusdump\\backup\\test\\$date" ; my $srcdir = "\\\\gwnas\\reliusdump\\backup\\tset" ; mkdir ($destdir, 0777) or warn "Cannot make directory: $!" ; my $rar = "RAR M -ep $destdir\\RA91sp0- -AGYYYYMMDD $srcdir\\*.* " ; # this creates the RAR command which is executed with bacticks later # M moves the files into the archive # ep removes the directories from the archive leaving just the file # -AG appends the year month day to the archive name open FILE, ">> rarlog.txt" || die "Cannot open rarlog.txt to append: $!\n" ; print FILE "--------------------------------------\n" ; print FILE sprintf (" Archive Created %04d-%02d-%02d %02d:%02d:%02d \n", $YYYY, $MM, $DD, $HH, $MN, $SS) ; print FILE "--------------------------------------\n\n" ; print FILE $rar ; print FILE "\n\n" ; print FILE `$rar` ; print FILE "\n\n" ; close FILE ;