-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilesync
More file actions
executable file
·36 lines (29 loc) · 785 Bytes
/
filesync
File metadata and controls
executable file
·36 lines (29 loc) · 785 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
34
35
36
#!/bin/bash
SSH="ssh -q"
REMOTE_HOST="username@remote.example.com"
REMOTE_SRC="/path/to/files"
LOCAL_DEST="/local/path"
source "$0.date" 2>/dev/null
[ -z "$LAST_RUN" ] && LAST_RUN="0000-01-01 00:00:00"
FILES="$($SSH $REMOTE_HOST find "'"$REMOTE_SRC"'" -newermt "'"$LAST_RUN"'" -type f -print 2>/dev/null)"
STAMP="$(date +%Y-%m-%d\ %H:%M:%S)"
IFS=$'\n'
echo "Which file should I copy [y/n on each]?"
echo
for f in $FILES; do
aw=""
while [ "$aw" != "y" -a "$aw" != "n" ]; do
echo -n " $f: "
read aw
done
if [ "$aw" = "y" ]; then
SOURCES+=" $REMOTE_HOST:'$f'"
fi
done
echo
if [ -z $SOURCES ]; then
echo "Nothing to copy ..."
else
eval rsync --progress -ze "'"$SSH"'"$SOURCES "'"$LOCAL_DEST"'"
[ $? -eq 0 ] && echo 'LAST_RUN="'"$STAMP"'"' >"$0.date"
fi