my @prefix_list = ();
my @file_list;
my $file_list_aref = \@file_list;
+my $opt_file;
my $opt_arch;
+my $opt_dir = "hld";
GetOptions ('h|help' => \$opt_help,
+ 'f|file=s' => \$opt_file,
's|start=s' => \$opt_startDate,
'e|end=s' => \$opt_endDate,
'p|prefix=s' => \@prefix_list,
- 'a|arch=s' => \$opt_arch);
+ 'a|arch=s' => \$opt_arch,
+ 'd|dir=s' => \$opt_dir
+ );
if( $opt_help ) {
&help();
exit(0);
}
-my $startSec = &date2sec($opt_startDate);
-my $endSec = &date2sec($opt_endDate);
-
-&getFileList();
-
+if(defined $opt_file){
+ &getFileListFromFile();
+}
+else{
+ &getFileList();
+}
&archive();
exit(0);
[-s|--start <date_time>] : Beginning of time interval.
[-t|--end <date_time>] : End of time interval.
[-p|--prefix <prefix>] : Archive only these prefixes.
+ [-f|--file <path>] : Path to hld file list.
[-a|--arch <archive>] : Archiving is done only with this option enabled.
+ [-d|--dir <path>] : Path to the file in the archive.
Examples:
Archive all hld files with prefixes 'st' and 'be' from sept 4th, 2010 to the archive hadessep10raw:
- date2tape.pl -p be -p st -s 2010-09-04_00:00:00 -e 2010-09-04_23:59:59 -a hadessep10raw
+ date2tape.pl -p be -p st -s 2010-09-04_00:00:00 -e 2010-09-04_23:59:59 -a hadessep10raw
+
+ Archive all hld files from the list /home/hadaq/kgoebel.txt to archive "hadesuser/kgoebel/hld/":
+ date2tape.pl -a hadesuser -d kgoebel/hld -f /home/hadaq/kgoebel.txt
EOF
}
{
my $retval = 0;
- unless( defined $opt_startDate ){
- print "Start date is not given!\n";
- $retval = -1;
- }
-
- unless( defined $opt_endDate ){
- print "End date is not given!\n";
- $retval = -1;
+ unless( defined $opt_file ){
+ unless( defined $opt_startDate ){
+ print "Start date is not given!\n";
+ $retval = -1;
+ }
+
+ unless( defined $opt_endDate ){
+ print "End date is not given!\n";
+ $retval = -1;
+ }
}
return $retval;
return $sec_epoch;
}
+sub getFileListFromFile()
+{
+ #- Get file list from $opt_file
+
+ my @tmp_list = `cat $opt_file`;
+
+ foreach my $file (@tmp_list){
+ chomp($file);
+ $file =~ s/^\s+//; # remove leading spaces
+ $file =~ s/\s+$//; # remove trailing spaces
+
+ push(@file_list, $file);
+ }
+}
+
sub getFileList()
{
+ my $startSec = &date2sec($opt_startDate);
+ my $endSec = &date2sec($opt_endDate);
+
#- Loop over disks
foreach my $diskNr (1..22){
my $path = sprintf("/data%02d/data", $diskNr);
my $archive = "archive";
$archive = $opt_arch if( defined $opt_arch);
- my $cmd = "gstore arch \"$hldfile\" $archive \"hld\"";
+ my $cmd = "gstore arch \"$hldfile\" $archive \"$opt_dir\"";
print "cmd: $cmd\n";
system($cmd) if( defined $opt_arch);
}