From 93cf7cf99a72cc9a6af670e846b479c37e07c2ac Mon Sep 17 00:00:00 2001 From: Martin Marrese Date: Thu, 26 Aug 2010 19:44:14 -0300 Subject: [PATCH] Make pinging hosts configurable Add a new configuration option to choose whether remote hosts should be pinged to check if they are up or not. Disabling this option is useful if your remote hosts don't reply to ICMP pings for security reasons. --- bacap | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bacap b/bacap index 42273ab..f72b6fd 100755 --- a/bacap +++ b/bacap @@ -27,6 +27,10 @@ BACKUP_PATH=/backup # Date format used for backed up directories (passed to the date command) DATE_FMT="%Y-%m-%d" +# Ping remote hosts to check if they are up (set to 0 if your hosts don't +# reply to ICMP pings). +PING_CHECK=1 + # rsync flags to use RSYNC_FLAGS="-aAXHx --numeric-ids --delete" @@ -77,7 +81,7 @@ perror() { echo "$@" >&2 } -host_up() { +ping_host() { ping -c1 "$1" > /dev/null 2>&1 } @@ -115,7 +119,7 @@ do [ -d "$dst" ] && perror "$dst already exists, skipping..." && continue - ! host_up $host && + [ "$PING_CHECK" -eq 1 ] && ! ping_host $host && perror "$host is down, skipping..." && continue [ -r "$exclude" ] && -- 2.43.0