#!/bin/bash # # This file can be used to check that fastback and fastback-unload-receipt # are working IF you can write a script that fetches the file back from # the remote ftp server: see ./fetch-from-remote # # You must rewrite fetch-from-remote for this to work correctly # # # ./fastback-check FILE [encrypt] [TICKET] # # where # FILE is the name of the file to test with # TICKET is the name of the ticket or the string "new" to # indicate that you what to specify "-n" to fastback # if specified as the second argument "encrypt" will cause -e to be # passed to fastback # the second and third arguments are optional # ORIG=$1 if [ ! -e $ORIG ]; then echo >&2 "Error: no such file $ORIG" exit 2 fi if [ "$2" = "encrypt" ]; then DO_ENCRYPT="-e" shift else DO_ENCRYPT="" fi if [ "$2" = "" ]; then DO_TICKET= elif [ "$2" = "new" ]; then DO_TICKET="-n" else DO_TICKET="-t $2" fi RECEIPT=GLRK-receipt fastback $DO_TICKET $DO_ENCRYPT $ORIG >$RECEIPT if [ ! -e $RECEIPT ]; then echo >&2 "Error: no such file $RECEIPT" exit 2 fi cat $RECEIPT | while read FIRST REST ; do #echo "FIRST:" $FIRST #echo "REST:" $REST if [ "$FIRST" = "FILE:" ]; then export FILE=$REST if [ -z "$FILE" ]; then echo >&2 "Error: file name missing from \"FILE:\" line" exit 2 fi #echo found FILE: $FILE fi if [ "$FIRST" = "END:" ]; then if [ -z "$FILE" ]; then echo >&2 "Error: no file name found in receipt: $RECEIPT" exit 2 fi ./fetch-from-remote $FILE fastback-unload-receipt $RECEIPT FETCHED=${FILE%.aes} # if the fetched file has a trailing .gz # but the orig doesn't then assume fastback did compression # and use zdiff to do compare if [ "$FETCHED" != "${FETCHED%.gz}" -a "$ORIG" = "${ORIG%.gz}" ]; then if ! zdiff $ORIG $FETCHED ; then echo "differ: ORIG ($ORIG) and FETCHED ($FETCHED)" else echo "same: ORIG: ($ORIG) and FETCHED ($FETCHED)" rm GLRK* fi else # otherwize just use diff if ! diff $ORIG $FETCHED ; then echo "differ: ORIG ($ORIG) and FETCHED ($FETCHED)" else echo "same: ORIG: ($ORIG) and FETCHED ($FETCHED)" rm GLRK* fi fi fi done