#! /bin/sh . $HOME/ftpsync.conf export RSYNC_PASSWORD PATH=/usr/gnu/bin:/usr/local/bin:/usr/bin:/bin export PATH #LOCK="${TO}/Archive-Update-in-Progress-`hostname -f`" LOCK="${TO}/Archive-Update-in-Progress-ftp.se.debian.org" # Get in the right directory and set the umask to be group writable # cd $HOME umask 022 # Check to see if another sync is in progress if /usr/local/bin/lockfile -! -l 43200 -r 0 "$LOCK"; then echo ftp is unable to start rsync, lock file exists exit 1 fi trap 'rm -f $LOCK > /dev/null 2>&1; echo "Done at \c" >> rsync.log; date >> rsync.log; savelog rsync.log > /dev/null' EXIT echo "Starting at \c" > rsync.log date >> rsync.log # echo "du start at \c" > du.log # date >> du.log # du -k /export/ftp/mirror/debian/ >> du.log 2>&1 & # sleep 600 # echo "Starting rsync after 600s wait at \c" >> rsync.log # date >> rsync.log /usr/local/bin/rsync -rltv \ --timeout 3600 \ --exclude "Archive-Update-in-Progress-ftp.se.debian.org" \ --exclude "project/trace/ftp.se.debian.org" \ --exclude "Packages*" \ --exclude "Release*" \ $EXCLUDE \ $RSYNC_USER@$RSYNC_HOST::debian $TO >> rsync.log 2>&1 if [ `grep -c '^total size is' rsync.log ` -ne 1 ]; then ( echo "Eeek. first rsync to debian broke down... Check logs.."; \ egrep '^write failed|@ERROR' rsync.log ) | mail -s "Debian sync failed" ftp-deb echo "Eeek. first rsync to debian broke down..." >> rsync.log exit 1 fi echo "first sync without delete done at \c" >> rsync.log date >> rsync.log /usr/local/bin/rsync -rltv --delete --delete-after \ --timeout 3600 \ --exclude "Archive-Update-in-Progress-ftp.se.debian.org" \ --exclude "project/trace/ftp.se.debian.org" \ $EXCLUDE \ $RSYNC_USER@$RSYNC_HOST::debian $TO >> rsync.log 2>&1 if [ `grep -c '^total size is' rsync.log ` -ne 2 ]; then ( echo "Eeek. second rsync to debian broke down... Check logs.."; \ grep '@ERROR' rsync.log ) | mail -s "Debian sync failed" ftp-deb echo "Eeek. second rsync to debian broke down..." >> rsync.log exit 2 fi echo "second sync with delete done at \c" >> rsync.log date >> rsync.log rm -f $LOCK > /dev/null 2>&1 #set +e #egrep 'ERROR|EOF|exiting|120[10] seconds' OLD/rsync.log.0 date -u > "${TO}/project/trace/ftp.se.debian.org" bin/runmirrors