-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathsync.sh
More file actions
executable file
·32 lines (24 loc) · 781 Bytes
/
sync.sh
File metadata and controls
executable file
·32 lines (24 loc) · 781 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
#!/bin/sh
set -e
echo "INFO: Starting sync.sh pid $$ $(date)"
if [ `lsof | grep $0 | wc -l | tr -d ' '` -gt 1 ]
then
echo "WARNING: A previous sync is still running. Skipping new sync command."
else
echo $$ > /tmp/sync.pid
if test "$(rclone ls --max-depth 1 $SYNC_SRC $RCLONE_OPTS)"; then
# the source directory is not empty
# it can be synced without clear data loss
echo "INFO: Starting rclone sync $SYNC_SRC $SYNC_DEST $RCLONE_OPTS $SYNC_OPTS"
rclone sync $SYNC_SRC $SYNC_DEST $RCLONE_OPTS $SYNC_OPTS
if [ -z "$CHECK_URL" ]
then
echo "INFO: Define CHECK_URL with https://healthchecks.io to monitor sync job"
else
wget $CHECK_URL -O /dev/null
fi
else
echo "WARNING: Source directory is empty. Skipping sync command."
fi
rm -f /tmp/sync.pid
fi