Menu

scripts_trove

consulare

Scripts Trove

Transferring gzip log files via scp

Transferring files whilst ensuring gzip is done, example done with Checkpoints.

~~~~~~

!/bin/sh -x

. /opt/CPshrd-R70/tmp/.CPprofile.sh
PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/opt/CPsuite-R70/fw1/:/opt/CPshrd-R70/lib/

grab yesterday date

date_us=date --date="1 day ago" +%m-%d-%y
FILE=$date_us.txt.gz
echo "Transferring $FILE"

check file is ok, no user using it

checkgz=fuser /var/Backuplog/$FILE | wc -w
count=1

0 is Ok

if [ ! $checkgz -eq 0 ]; then

Max wait: 5min * 50

    while [ ! $checkgz -eq 0 ]  &&  [ $count -lt 50 ];
    do
            echo "Waiting [$count]"
            sleep 5m
            count=`expr $count + 1`
            checkgz=`fuser /var/Backuplog/$FILE | wc -w`
    done

fi

Check gzip integrity

echo "File is available, checking integrity"
checkgz=gzip -t /var/Backuplog/$FILE 2>&1 | wc -l
if [ $checkgz -eq 0 ]; then
echo "File checks OK"
else
echo "Bad gzip !"
exit -1
fi

scp, unprotected key

scp -BCp -i /scripts/esis /var/Backuplog/$FILE esis-incoming-scp@192.168.1.1:~/checkpoint


Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.