Shell Script Does not complete if rsync returns Code 24

John Gallagher john.gallagher at ciosystems.com
Wed Jan 11 03:28:00 GMT 2006


I have a simple backup shell script that I am using for backups.  

I have a problem which I think is a result of this error: 

rsync warning: some files vanished before they could be transferred (code
24) at main.c(789)

Any command after the rsync never gets executed if I get the above error.
The file system is very large and we have engineers working at all hours so
it is rare that this would complete with out the code 24 error.

I am using rsync-2.6.4-3.

I read the FAQ which describes how to write a wrapper.

http://samba.anu.edu.au/rsync/FAQ.html

The problem is that I have no clue what to do with this and or how to make
it work with my script.

Any help would be appreciated.

The script follows:

#!/bin/sh -e
# Assumes the existence of
#${DIR_BKUP_ROOT}/{Hour-1, Hour-2.....}

DIR_BKUP_ROOT="/data1/backup/Hourly"
backup=`cat /etc/snapshot/include.text`
excludefile=/etc/snapshot/exclude.text
INDEX=`cat /data1/backup/Hourly/last-bk.txt`
RM="/bin/rm"
CP="/bin/cp"
RSYNC="/usr/bin/rsync"
DATE="/bin/date"

[ -x $RM -a -x $CP -a -x $RSYNC -a -x $DATE ] || exit 1

if [ -f ${DIR_BKUP_ROOT}/bk-stats.txt ]; then
                  $RM -f ${DIR_BKUP_ROOT}/bk-stats.txt
fi

echo Last backup $NEXTHOURLY started on `date` >>
${DIR_BKUP_ROOT}/bk-stats.txt

case "$INDEX" in
        'Hour-1')
                NEXTHOURLY="Hour-2"
                PREVBACK="Hour-1"
                CLEANUP="Hour-3"
        ;;
        'Hour-2')
                NEXTHOURLY="Hour-3"
                PREVBACK="Hour-2"
                CLEANUP="Hour-4"
        ;;
        'Hour-3')
                NEXTHOURLY="Hour-4"
                PREVBACK="Hour-3"
                CLEANUP="Hour-5"
        ;;
        'Hour-4')
                NEXTHOURLY="Hour-5"
                PREVBACK="Hour-4"
                CLEANUP="Hour-1"
        ;;
        'Hour-5')
                NEXTHOURLY="Hour-1"
                PREVBACK="Hour-5"
                CLEANUP="Hour-2"
        ;;
        *)
                echo "ERROR: Invalid hour!"
                exit 2
        ;;
esac
#
if [ -f ${DIR_BKUP_ROOT}/last-bk.txt ]; then
                  $RM -f ${DIR_BKUP_ROOT}/last-bk.txt
fi
#
if [ -d ${DIR_BKUP_ROOT}/$NEXTHOURLY ]; then
                $RM -rf ${DIR_BKUP_ROOT}/$NEXTHOURLY
fi
#
echo $NEXTHOURLY >> ${DIR_BKUP_ROOT}/last-bk.txt
#
#
#if [ -f ${DIR_BKUP_ROOT}/last-bk.txt ]; then
$RSYNC -R -a --exclude-from=$excludefile
--link-dest=${DIR_BKUP_ROOT}/${PREVBACK} $backup
${DIR_BKUP_ROOT}/${NEXTHOURLY}/
#fi
echo  $NEXTHOURLY backup completed `date` >> ${DIR_BKUP_ROOT}/bk-stats.txt
if [ -d ${DIR_BKUP_ROOT}/$CLEANUP ]; then
                $RM -rf ${DIR_BKUP_ROOT}/$CLEANUP
fi
echo  The removal of $CLEANUP completed `date` >>
${DIR_BKUP_ROOT}/bk-stats.txt
exit 0


------------------------------------
CIO Systems
John Gallagher
www.ciosystems.com
------------------------------------



More information about the rsync mailing list