Add 3 times retry and 30m+30m rsync timeout to syncHttpLogs

This commit is contained in:
Adam Saleh 2021-07-21 16:05:42 +02:00
parent fca9cbad46
commit 721e3e9864

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
RSYNC_FLAGS='-avSHP --no-motd' RSYNC_FLAGS='-avSHP --no-motd --timeout=1200 --contimeout=1200'
DEBUG=1 DEBUG=1
function syncHttpLogs { function syncHttpLogs {
@ -23,13 +23,15 @@ function syncHttpLogs {
RSYNC_OUTPUT=$(/usr/bin/rsync $RSYNC_FLAGS --list-only $HOST::log/httpd/*$YESTERDAY* | grep xz$ | awk '{ print $5 }' ) RSYNC_OUTPUT=$(/usr/bin/rsync $RSYNC_FLAGS --list-only $HOST::log/httpd/*$YESTERDAY* | grep xz$ | awk '{ print $5 }' )
for f in ${RSYNC_OUTPUT}; do for f in ${RSYNC_OUTPUT}; do
DEST=$(echo $f | /bin/sed s/-$YESTERDAY//) DEST=$(echo $f | /bin/sed s/-$YESTERDAY//)
if [[ ${DEBUG} -eq 1 ]]; then if [[ ${DEBUG} -eq 1 ]]; then
echo "${HOST}: Getting ${RSYNC_OUTPUT} and saving to ${DEST}" echo "${HOST}: Getting ${RSYNC_OUTPUT} and saving to ${DEST}"
fi fi
/usr/bin/rsync $RSYNC_FLAGS $HOST::log/httpd/$f ./$DEST &> /dev/null for i in 2 1 0; do
if [[ $? -ne 0 ]]; then timeout 12h /usr/bin/rsync $RSYNC_FLAGS $HOST::log/httpd/$f ./$DEST &> /dev/null && break
echo "rsync from $HOST for file $f failed" if [[ $? -ne 0 ]]; then
fi echo "rsync from $HOST for file $f failed, will repeat $i times"
fi
done
done done
done done
} }