summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xssync20
1 files changed, 11 insertions, 9 deletions
diff --git a/ssync b/ssync
index 5396be0..6ac0496 100755
--- a/ssync
+++ b/ssync
@@ -1,21 +1,19 @@
#!/usr/bin/env bash
set -ex
-if [ $# -lt 3 ]; then
- echo "Usage: ssync KEY_FILE REMOTE_DIR SRC_DIR"
+if [ $# -lt 4 ]; then
+ echo "Usage: ssync KEY_FILE REMOTE REMOTE_DIR SRC_DIR"
exit 1
fi
KEY_FILE=$1
-REMOTE_DIR=$2
-SRC_DIR=$3
+REMOTE=$2
+REMOTE_DIR=$3
+SRC_DIR=$4
LASTRAN_DIR=$HOME/.local/ssync
LASTRAN_FILE=$LASTRAN_DIR/.lastran
NEXT_RUN_DATE=$(date -Is)
-PREV_RUN_DATE=$(cat $HOME/.local/ssync/.lastran)
-
-echo "Failsafe - Running at: $NEXT_RUN_DATE - if failed to write use this timestamp in $LASTRAN_FILE"
if [ ! -f $LASTRAN_FILE ]; then
mkdir -p $LASTRAN_DIR
@@ -30,12 +28,16 @@ if [ $PREV_RUN_DATE == "" ]; then
exit 0;
fi
+PREV_RUN_DATE=$(cat $HOME/.local/ssync/.lastran)
+
+echo "Failsafe - Running at: $NEXT_RUN_DATE - if failed to write use this timestamp in $LASTRAN_FILE"
+
echo "Syncing files since: $PREV_RUN_DATE"
rsync -e "ssh -i $KEY_FILE" \
-av \
- --files-from=<(ssh -i $KEY_FILE billserver "find ${REMOTE_DIR} -newermt ${PREV_RUN_DATE} -exec realpath --relative-to ${REMOTE_DIR} {} \;") \
- billserver:${REMOTE_DIR} ${SRC_DIR}
+ --files-from=<(ssh -i $KEY_FILE $REMOTE "find ${REMOTE_DIR} -newermt ${PREV_RUN_DATE} -exec realpath --relative-to ${REMOTE_DIR} {} \;") \
+ $REMOTE:${REMOTE_DIR} ${SRC_DIR}
echo $NEXT_RUN_DATE > $LASTRAN_FILE
echo "Done syncing"