#!/bin/bash #This script is used to remake the archive directory tree # when the USB disk has errors when copied in Boulder. #This script uses a begin and end YYYYMMDD string to recreate # the archive directory tree to USB disk. #The script is called with a DiskToPath, BegYMD and EndYMD, where # DiskToPath is the path to the USB disk (eg. /media/usbdisk) # BegYMD is the first day of the archive to recreate # EndYMD is the last day of the archive to recreate # #David Welsh #April 26, 2005 #Set the path export PATH=$HOME/bin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin remake() { indir=$1 outdir=$2 bdelta=$3 edelta=$4 getprog=$5 instr=${1##/*/} echo " "remaking data from "$indir" to "$outdir" cd "$indir" # echo `pwd` let delta=$bdelta while [ $delta -le $edelta ]; do date=`$getprog "$delta"` echo date: "$date" if ls *"$date"* > /dev/null ; then cp *"$date"* "$outdir" echo found file for "$date" fi let delta=delta+1 done #generate the check sum cd "$outdir" cksum * > "$disktopath"/cksum."$instr" } #Check that there are three arguments if [ $# = 3 ]; then echo " Start RemakeArchiveData.bash `date -u`" #get the USB disk mount point, beg and end YYYYMMDD disktopath=$1 begymd=$2 endymd=$3 #conver the YYYYMMDD to delta days readymd $begymd $endymd > /tmp/readymd.out read bd ed < /tmp/readymd.out remake /data/search/hsrl "$disktopath"/search/hsrl $bd $ed getymd remake /data/search/mwrad "$disktopath"/search/mwrad $bd $ed getMWRadymd remake /data/search/mmcr/mom "$disktopath"/search/mmcr/mom $bd $ed getjday remake /data/search/mmcr/spc "$disktopath"/search/mmcr/spc $bd $ed getjday remake /data/search/qc/quicklooks "$disktopath"/search/mmcr/quicklooks $bd $ed getymd remake /data/search/qc/summary "$disktopath"/search/mmcr/summary $bd $ed getymd echo " Stop RemakeArchiveData.bash `date -u`" else echo " Usage: RemakeArchiveData.bash DiskToPath BegYMD EndYMD" fi