From 9832914e35542443c4db1ff972c255524280e957 Mon Sep 17 00:00:00 2001 From: Holger Levsen Date: Fri, 25 Jan 2013 10:17:34 +0100 Subject: [PATCH] fix liveboot_rsync to not fail (completly) if a destination datacenter is down (like pbb-de atm) --- liveboot_rsync.sh | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/liveboot_rsync.sh b/liveboot_rsync.sh index d27d765..e045359 100755 --- a/liveboot_rsync.sh +++ b/liveboot_rsync.sh @@ -1,13 +1,12 @@ #!/bin/bash -# copyright 2012 Holger Levsen +# copyright 2012,2013 Holger Levsen # GPL2 licenced set -e #set -x export - # # Define default settings # @@ -25,6 +24,20 @@ RSYNC_DST4="liveboot@10.252.1.1/liveboot/" # dc1+2 (mgmt1) RSYNC_DST5="liveboot@10.1.1.1/liveboot/" +ping_and_rsync() { + # + # only try to rsync if destination is pingable + # + if ping -c 1 $(echo $1 | sed -s 's#.*@\([0-9.]*\).*#\1#' ) > /dev/null ; then + echo "Now rsyncing results to $1 ..." + rsync --password-file /etc/rsynclivebuild-send.pass -avv --delete --delete-excluded $RSYNC_FILTER $RSYNC_SRC/ rsync://$1 + figlet "$2 OK" + else + echo "Warning: $1 down." + echo "Warning: $2 failed." + fi +} + # # check if another rsync is running # @@ -37,21 +50,11 @@ done # Mirror # echo -echo "Now rsyncing results to $RSYNC_DST1 ..." -rsync --password-file /etc/rsynclivebuild-send.pass -avv --delete --delete-excluded $RSYNC_FILTER $RSYNC_SRC/ rsync://$RSYNC_DST1 -figlet "mirror to r+i OK" -echo "Now rsyncing results to $RSYNC_DST2 ..." -rsync --password-file /etc/rsynclivebuild-send.pass -avv --delete --delete-excluded $RSYNC_FILTER $RSYNC_SRC/ rsync://$RSYNC_DST2 -figlet "mirror to storage-dc OK" -echo "Now rsyncing results to $RSYNC_DST3 ..." -rsync --password-file /etc/rsynclivebuild-send.pass -avv --delete --delete-excluded $RSYNC_FILTER $RSYNC_SRC/ rsync://$RSYNC_DST3 -figlet "mirror to pbb OK" -echo "Now rsyncing results to $RSYNC_DST4 ..." -rsync --password-file /etc/rsynclivebuild-send.pass -avv --delete --delete-excluded $RSYNC_FILTER $RSYNC_SRC/ rsync://$RSYNC_DST4 -figlet "mirror to staging OK" -echo "Now rsyncing results to $RSYNC_DST5 ..." -rsync --password-file /etc/rsynclivebuild-send.pass -avv --delete --delete-excluded $RSYNC_FILTER $RSYNC_SRC/ rsync://$RSYNC_DST5 -figlet "mirror to DC1+2 OK" +ping_and_rsync $RSYNC_DST1 "mirror to r+i" +ping_and_rsync $RSYNC_DST2 "mirror to storage-dc" +ping_and_rsync $RSYNC_DST3 "mirror to pbb" +ping_and_rsync $RSYNC_DST4 "mirror to staging" +ping_and_rsync $RSYNC_DST5 "mirror to DC1+2" du -sh /srv/mirror/liveboot figlet "OK" -- 2.39.5