summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill <bill@billserver.senders.io>2021-04-28 12:12:00 -0400
committerBill <bill@billserver.senders.io>2021-04-28 12:12:00 -0400
commitb72e7b2afe9452503b60a28329067fea17a54967 (patch)
tree8968d07128db4e8c639b560889ffde1e838dd7a5
parent92cb5dce6294969c213c81d75d062a2d9b622a8a (diff)
Log different msg when no files vs no new files
For debugging it can be helpful to see when we've listed files but nothing to sync vs when we've found nothing to get at all.
-rwxr-xr-xssync35
1 files changed, 21 insertions, 14 deletions
diff --git a/ssync b/ssync
index 622c3cd..b50ded2 100755
--- a/ssync
+++ b/ssync
@@ -54,23 +54,30 @@ log "Syncing files since: $PREV_RUN_DATE"
log "Fetching files"
mkdir -p $RUN_DIR
ssh -i $KEY_FILE $REMOTE "find ${REMOTE_DIR} -type f -newermt ${PREV_RUN_DATE} -exec realpath --relative-to ${REMOTE_DIR} {} \;" >> $CURGET_FILE
-comm -23 <(sort -u $CURGET_FILE) <(sort -u $FETCHED_FILE) > $FETCH_FILE
-COUNT=$(wc -l $FETCH_FILE | cut -d' ' -f1)
+GET_COUNT=$(wc -l $CURGET_FILE | cut -d' ' -f1)
-if [ $COUNT -gt 0 ]; then
- #
- # Syncing
- #
- log "Found ${COUNT} files to fetch"
+if [ $GET_COUNT -gt 0 ]; then
+ comm -23 <(sort -u $CURGET_FILE) <(sort -u $FETCHED_FILE) > $FETCH_FILE
+ COUNT=$(wc -l $FETCH_FILE | cut -d' ' -f1)
- cat $FETCH_FILE >> $FETCHED_FILE
- log "Wrote files to fetched files"
- log "Syncing now"
- cat $FETCH_FILE | xargs -n1 -P$PARALLEL -I '{}' rsync -e "ssh -i $KEY_FILE" \
- -av \
- $REMOTE:"${REMOTE_DIR}/'{}'" ${SRC_DIR}
+ if [ $COUNT -gt 0 ]; then
+ #
+ # Syncing
+ #
+ log "Found ${COUNT} files to fetch"
+
+ cat $FETCH_FILE >> $FETCHED_FILE
+ log "Wrote files to fetched files"
+ log "Syncing now"
+ cat $FETCH_FILE | xargs -n1 -P$PARALLEL -I '{}' rsync -e "ssh -i $KEY_FILE" \
+ -av \
+ $REMOTE:"${REMOTE_DIR}/'{}'" ${SRC_DIR}
+ else
+ log "No files to sync - deleting $CURGET_FILE"
+ rm -f $CURGET_FILE
+ fi
else
- log "No files to sync - deleting $CURGET_FILE"
+ log "No new files found - deleting $CURGET_FILE"
rm -f $CURGET_FILE
fi