From 73e2aa4cee08900882d77cb94a74c338aa9740f2 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 12 Apr 2023 11:49:55 +0800 Subject: Update --- bin/task/context | 3 ++- bin/unix/rsync_retry.sh | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 bin/unix/rsync_retry.sh diff --git a/bin/task/context b/bin/task/context index c8e3f7a..fd10baf 100755 --- a/bin/task/context +++ b/bin/task/context @@ -7,10 +7,11 @@ # # TODO support minus time -LOG_FILE=~/log/.context && touch $LOG_FILE +LOG_FILE=~/.context && touch $LOG_FILE PLAN_FILE=~/log/plan.context.md PROC=$$ trap 'exit 1' SIGUSR1 +trap 'rsync_retry $0' EXIT context="$(cat ~/.task/context)" [[ "$*" =~ '-s' ]] && SET=true && shift diff --git a/bin/unix/rsync_retry.sh b/bin/unix/rsync_retry.sh new file mode 100755 index 0000000..be70c03 --- /dev/null +++ b/bin/unix/rsync_retry.sh @@ -0,0 +1,14 @@ +#! /bin/sh + +REMOTE=${REMOTE:-vps} +SRC="$1" +DEST="$2" +DEST="${DEST:-$1}" + +# If fail to sync file, then +if rsync -au "${SRC}" ${REMOTE}:"${DEST}"; then + rm "${SRC}".retry 2>/dev/null + true +else + echo ${DEST} >${SRC}.retry +fi -- cgit v1.2.3-70-g09d2