-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathmysync
More file actions
executable file
·73 lines (72 loc) · 2.64 KB
/
mysync
File metadata and controls
executable file
·73 lines (72 loc) · 2.64 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
# @since Oct 22, 2009
# @ver May 23, 2012
#
####### RESULTS EXPLANATION ############
# The first character indicates what is happening to the file:
#
# < means that a file is being transferred to the remote host (sent).
# > means that a file is being transferred to the local host (received).
# c means that a local change/creation is occurring for the item (such as the creation of a directory or the changing of a symlink, etc.).
# h means that the item is a hard link to another item (requires --hard-links).
# . means that the item is not being updated (though it might have attributes that are being modified).
# * means that the rest of the itemized-output area contains a message (e.g. "deleting").
#
# The second character indicates what type of directory entry it is. Specifically:
#
# f for file
# d for directory
# L for symbolic link
# D for device
# S for special file (e.g. socket or fifo)
#
# The remaining columns are described below:
#
# c means either that a regular file has a different checksum or that a symlink, device, or special file has a changed value.
# s means the size of a regular file is different and will be updated by the file transfer.
# t or T:
# t means the modification time is different and is being updated to the sender's value
# T means that the modification time will be set to the transfer time
# p means the permissions are different and are being updated to the sender's value
# o means the owner is different and is being updated to the sender's value
# g means the group is different and is being updated to the sender's value
# . unused
#
# The following columns may not be present, depending on your transfer options
#
# a means that the ACL information changed
# x means that the extended attribute information changed
DEBUG=0;
function mysync
{
for DEST in $TO; do
SERVER=${DEST%:*}
SERVER=${SERVER#*@}
if [ "$DESC" == "" ]; then
DESC=$SERVER;
fi
if [ "$ASK" == "Y" ]; then
echo "Update $DESC ? [ENTER to update, ESC to skip] "
read -s -n1 DOIT
else
DOIT=""
fi
if [ "$DOIT" != $'\e' ]; then
if [ "$DEBUG" == 0 ]; then
echo >> $LOG.$SERVER
echo "##############################################################" >> $LOG.$SERVER
date >> $LOG.$SERVER
echo "##############################################################" >> $LOG.$SERVER
echo >> $LOG.$SERVER
else
ROPTS="$ROPTS --dry-run -v"
fi
CMD="rsync $ROPTS $FROM $DEST"
RES=$(eval $CMD)
if [ "$DEBUG" == 0 ]; then
echo "$RES" >> $LOG.$SERVER
fi
echo "$RES"
fi
done
}