#!/bin/sh
#
# Script to backup a directory to the NCAR High Performance Storage System
# Linux version uses gzip flag on tar command
#
# Written by Stan Solomon, 3/11
# Based on a mass store script provided by Astrid Maute, circa y2k
# Updated to use HSI commands
# Limitations:  You must have access to a large temporary storage area
#               Maximum file size 1 TB
#
#
# Edit lines 17, 20, 23, and 26 to specify directories and filename
#
#
# Your local directory to be backed up:
localdir=/local/d/joemci
#
# Your temporary storage area:
tempdir=/hao/aim3/joemci/backups
#
# Your HPSS backups directory:
hpssdir=/home/joemci/backups
#
# Your name for the backup file (date will be appended):
bfname=backup_local_d_joemci_
#
#
# Tar and gzip the entire directory:
tarfile=$bfname`date '+%y_%m_%d'`.tar.gz
echo 'creating file' $tempdir/$tarfile
cd $localdir
echo 'tarring' $localdir
tar -czf $tempdir/$tarfile .
echo 'tar completed'
#
# Copy the compressed tarfile to the HPSS:
echo 'copying' $tempdir/$tarfile 'to HPSS'
hsi put $tempdir/$tarfile : $hpssdir/$tarfile
echo 'copy completed'
echo ' '
echo 'listing of HPSS:'$hpssdir
hsi ls -lR $hpssdir
#
# Reminder:
echo ' '
echo 'remove file' $tempdir/$tarfile
echo 'after verifying copy to HPSS'
#
exit
