diff --git a/.synccmd.sh b/.synccmd.sh index ce6d85a..d85e23a 100755 --- a/.synccmd.sh +++ b/.synccmd.sh @@ -29,18 +29,16 @@ sync() { if [ ! -f $logfile ]; then touch $logfile fi - echo $src - echo $logfile - echo $syncloopfile # PUSH TO REMOTE - and PULL FROM REMOTE swapping `src` with `dest` #echo "executing rsync -aPu --log-file=$LOGFILE -e ssh $otheropts $src $dest" # NOTE REMOTEDIR ALREADY EXISTS IN DESTINATION # in this form rsync receive only data from source 1>$syncloopfile 2>&1 rsync -ni -aPu --progress --out-format="%i ${GREEN}%n%L${ENDCOLOR} %''b" --log-file=$logfile -e ssh $otheropts $src $dest | \ - grep -e "[<|>]" | \ - sed -E "s~<(\w|\W){10}~\\${PURPLE}Sending\\${ENDCOLOR} TO ${dest}~g" | \ - sed -E "s~>(\w|\W){10}~\\${CYAN}Receiving\\${ENDCOLOR} FROM ${src}~g" | \ - xargs -0 printf 1>>$syncloopfile 2>&1 + grep -E "(<|>|deleting)" | \ + sed -E "s~<(\w|\W){10}~\\${PURPLE}\[SEND\]\\${ENDCOLOR} to remote ~g" | \ + sed -E "s~>(\w|\W){10}~\\${PURPLE}\[RECEIVE\]\\${ENDCOLOR} from remote ~g" | \ + sed -E "s~\*deleting(\s)*~\\${PURPLE}\[DELETE\]\\${ENDCOLOR} in local ~g" | \ + xargs -r -0 printf 1>>$syncloopfile 2>&1 # last command execution exit code $?" rsync_result=$? if [[ ${rsync_result} -ne 0 ]]; then diff --git a/syncloop.sh b/syncloop.sh index fb12714..fe9c58c 100755 --- a/syncloop.sh +++ b/syncloop.sh @@ -70,9 +70,9 @@ synccycle() { if [ -f "$tmpqueuedeletes" ]; then ndeletes=$(wc -l < ${tmpqueuedeletes}) while [ $ndeletes -gt 0 ]; do - echo -n -e "syncloop delete at remote: ${RED}$(head -n $ndeletes ${tmpqueuedeletes} | tr '\n', ' ')${ENDCOLOR}" + echo -e "${PURPLE}[DELETE]${ENDCOLOR} at remote: ${RED}$(head -n $ndeletes ${tmpqueuedeletes} | tr '\n', ' ')${ENDCOLOR}" ssh $REMOTEHOST "rm -rf $(head -n $ndeletes ${tmpqueuedeletes} | tr '\n', ' ')" - echo -e " ${PURPLE}DONE${ENDCOLOR}" + echo -e " ${PURPLE}[DONE]${ENDCOLOR}" # remove the first ndeletes lines flock $lock_deletes tmpfile=$(mktemp) @@ -89,9 +89,8 @@ synccycle() { nqueue=$(wc -l < ${tmpqueuefile}) while [ $nqueue -gt 0 ]; do #echo "${tmpqueuefile} not empty consume ${nqueue} updates in queue" - echo -n "syncloop START SYNC" sync $LOCALPATH_HASH $LOCALPATH $REMOTEPATH - echo -e " ${PURPLE}DONE${ENDCOLOR}" + echo -e "${PURPLE}[DONE]${ENDCOLOR}" # remove the first nqueue lines from queue flock $lock_queue tmpfile=$(mktemp) @@ -108,9 +107,9 @@ synccycle() { elapsed="$(bc <<<"$now-$lastsynctime")" ## if elapsed is greater than maxpulllimit sync from remote with delete option if [ 1 -eq $(echo "$elapsed>$maxpulllimit" | bc) ]; then - echo -n "syncloop $maxpulllimit seconds reached: sync from remote with --delete option..." + echo -e "${PURPLE}[PULL LIMIT]${ENDCOLOR} $maxpulllimit seconds reached: sync from remote with --delete option..." sync $LOCALPATH_HASH $REMOTEPATH $LOCALPATH '--delete' - echo -e " ${PURPLE}DONE${ENDCOLOR}" + echo -e "${PURPLE}[PULL LIMIT DONE]${ENDCOLOR}" lastsynctime="$(date -u +%s.%N)" ## increment the pull iteration or reset it if [ ${pulliteration} -eq ${maxpulliteration} ]; then