#!/usr/bin/perl -w ########################################################################### # # # This script synchronizes files from a local machine to and from # # HPSS using the "hsi" command line tool. # # # # Copyright 2009 Theodore S. Kisner # # # # Redistribution and use in source and binary forms, with or without # # modification, are permitted provided that the following conditions # # are met: # # # # 1. Redistributions of source code must retain the above copyright # # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # # notice, this list of conditions and the following disclaimer in the # # documentation and/or other materials provided with the distribution. # # # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # # DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, # # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # # POSSIBILITY OF SUCH DAMAGE. # ########################################################################### use strict; use POSIX; use Getopt::Std; use File::Basename; use File::stat; use File::Path; use Time::Local; # The version of this program my $version = "1.1"; # The path to the "hsi" command my $hsiexec = "hsi"; # Mapping from HPSS month string to POSIX number my %month2num = qw( Jan 0 Feb 1 Mar 2 Apr 3 May 4 Jun 5 Jul 6 Aug 7 Sep 8 Oct 9 Nov 10 Dec 11 ); # The list of local files newer than HPSS my @files_lnew = (); # The list of HPSS files newer than local disk my @files_hnew = (); # The list of HPSS files that do not exist locally my @files_honly = (); # The list of local files that do not exist on HPSS my @files_lonly = (); # The HPSS list of actions my @hpss_actions_commit = (); my @hpss_actions_update = (); # The list of local actions my @local_actions_commit = (); my @local_actions_update = (); # The name of the per-directory files containing HPSS location my $syncfile = ".synchsi"; # The current date and time my $now = time(); my @nowdate = localtime($now); # The current year my $thisyear = 1900 + $nowdate[5]; # The name of the temporary HPSS execution list my $hpsscomfile = "hsync-TEMP_".$now; # Useage information sub useage { print "\n<**************************************************************>\n\n"; print " Usage: hsync [] [