root/branches/newmole/scripts/weekly_backup.pl

Revision 688, 4.6 kB (checked in by peter, 2 years ago)

Merge changes from mainline upto r685 (second installment).

Mop up a few remaining issues.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1#!perl -w
2# in above -w turns on some warnings
3
4# perl script to back up the cloudy source files onto a different computer
5# this is automatically executed once per week, early Saturday morning
6# files go to cdrw_dir which should be an accessible cdrw drive,
7# and also to out_dir
8
9# bring in the perl module that includes copy
10use File::Copy;
11
12# the disk drive where the original files and results live, we will back this up
13$c = "c";
14# input and output directories
15$in_dir = "$c:/projects/cloudy/trunk/tsuite/auto/";
16
17# this is the letter of the cdrw drive on the network
18# this now (mid '05) is on thunder
19# on 05 oct 01 free space on cloudy_bk was 664 mb full space 703mb
20$cdrw_dir = "j:/";
21# this is the raid drive on cumulus
22$out_dir = "$c:/storage/backup/cloudy/";
23
24# get current time and date
25($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
26                                            gmtime(time);
27# create basename for file
28$basename = "$year"."$mon"."$mday" ;
29
30# move to the directory, which contains source.tar and
31if( !chdir( $in_dir ) )
32{
33   printf(" invalid directory for output of test suite\n");
34   printf(" was ==%s==\n",$in_dir );
35   # send email 
36   send_mail_fail();
37   exit(1);
38}
39
40# create fully resolved names for where the files will end up
41$exe = "$out_dir"."$basename".".exe" ;
42$source = "$out_dir"."$basename".".src.tar";
43$dat = "$out_dir"."$basename".".data.tar";
44$hazy = "$out_dir"."$basename".".hazy.tar";
45$agn = "$out_dir"."$basename".".agn.tar";
46$tsuite = "$out_dir"."$basename".".tsuite.tar";
47
48# these files live in tsuite/auto and were created by
49# last night's run of current\unix\copy_files.pl
50if( !copy( "cloudy.exe" , $exe ) )
51{
52   printf(" weekly backup could not copy cloudy\n");
53   send_mail_fail();
54   exit(1);
55}
56if( !copy( "source.tar" , $source ) )
57{
58   printf(" weekly backup could not copy source\n");
59   send_mail_fail();
60   exit(1);
61}
62if( !copy( "data.tar"   , $dat ) )
63{
64   printf(" weekly backup could not copy data\n");
65   send_mail_fail();
66   exit(1);
67}
68if( !copy( "tsuite.tar" , $tsuite ) )
69{
70   printf(" weekly backup could not copy tsuite\n");
71   send_mail_fail();
72   exit(1);
73}
74
75#=========================================================
76# make backup copy of hazy
77$hazy_dir= "$c:/projects/";
78# move to the hazy directory
79if( !chdir( $hazy_dir ) )
80{
81        printf(" invalid directory for hazy\n");
82        printf(" was ==%s==\n",$hazy_dir );
83        send_mail_fail();
84        exit(1);
85}
86system(
87"tar_mks -cvf \"$hazy\" hazy/*.doc hazy/*.jnb ");
88#=========================================================
89
90#make backup copy of agn
91#$agn_dir= "c:/projects/";
92#if( !chdir( $agn_dir ) )
93#{
94#       printf(" invalid directory for agn\n");
95#       printf(" was ==%s==\n",$agn_dir );
96#       exit(1);
97#}
98# make backup copy of agn word docs
99#system(
100#"tar_mks -cvf \"$agn\" agn/*.doc agn/*/*.doc ");
101#=========================================================
102
103# move to the saved files directory on another computer,
104# which contains the tar files we just copied over
105if( !chdir( $out_dir ) )
106{
107        printf(" invalid directory for output of test suite\n");
108        printf(" was ==%s==\n",$out_dir );
109        send_mail_fail();
110        exit(1);
111}
112# have to delete existing files since gzip will hang waiting for response on overwrite
113if( -e "$tsuite".".gz" )
114{
115        unlink( "$tsuite".".gz" );
116}
117if( -e "$exe".".gz" )
118{
119        unlink( "$exe".".gz" );
120}
121if( -e "$source".".gz" )
122{
123        unlink( "$source".".gz" );
124}
125if( -e "$dat".".gz" )
126{
127        unlink( "$dat".".gz" );
128}
129if( -e "$hazy".".gz" )
130{
131        unlink( "$hazy".".gz" );
132}
133#if( -e "$agn".".gz" )
134#{
135#       unlink( "$agn".".gz" );
136#}
137
138system( "gzip $exe" );
139system( "gzip $tsuite" );
140system( "gzip $source" );
141system( "gzip $dat" );
142system( "gzip $hazy" );
143#system( "gzip $agn" );
144
145# copy it to the cdrw
146
147copy( "$exe.gz"    , $cdrw_dir );
148copy( "$tsuite.gz" , $cdrw_dir );
149copy( "$source.gz" , $cdrw_dir );
150copy( "$dat.gz"    , $cdrw_dir );
151copy( "$hazy.gz"   , $cdrw_dir );
152#copy( "$agn.gz"    , $cdrw_dir );
153
154# send email does work
155send_mail();
156exit;
157
158
159#=============================================================
160#             send_mail(),
161#=============================================================
162
163sub send_mail {
164 
165   open( ioLOG , ">backup.txt" );
166
167   printf( ioLOG " exe, data, and source backed up to cumulus storage.\n"); 
168   printf( ioLOG " file name was %s\n", $basename) ;
169   close( ioLOG );
170   system("c:\\u\\blat\\blat.exe backup.txt -t gary\@pa.uky.edu -s CloudyBackup " );
171 
172}
173
174sub send_mail_fail {
175 
176   open( ioLOG , ">backup.txt" );
177
178   printf( ioLOG " weekly_backup.pl had trouble doing backups.\n"); 
179   close( ioLOG );
180   system("c:\\u\\blat\\blat.exe backup.txt -t gary\@pa.uky.edu -s CloudyBackup " );
181 
182}
Note: See TracBrowser for help on using the browser.