-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample2.sh
More file actions
executable file
·33 lines (27 loc) · 941 Bytes
/
example2.sh
File metadata and controls
executable file
·33 lines (27 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
#. /path/to/sync-utils.sh || {
# echo Failed to load sync-utils.sh >&2
# exit 1
#}
. "$(dirname -- "$0")"/sync-utils.sh || {
echo Failed to load sync-utils.sh >&2
exit 1
}
URL=rsync://example.com/example
DST=/path/to/sync/dir
TEMP_DIR=/path/to/temp/dir
# The following one job is interruptible. For example, killed by tunasync when
# `tunasync stop job-name` is run by user manually.
run-sync-job rsync --temp-dir="$TEMP_DIR" some-other-args "$SRC" "$DST"
# using the exit status to tell caller whether the job success is IMPORTANT!
ret=$?
# If rsync failed, it might leave some temporary files.
if [ $ret != 0 ]; then
# with signals blocked, it should not run for too long.
rm -rf "$TEMP_DIR"
# If we are unsure that whether time needed by the cleanup is short enough,
# we can use the following one instead:
#timeout 1 rm -rf "$TEMP_DIR"
fi
# return the status of sync
exit $ret