-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.rsync-rc
90 lines (81 loc) · 2.25 KB
/
.rsync-rc
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env bash
alias edp=explode-parent-dirs
rsync_only() {
arg="$1"
shift
rsync -avzh --include="$arg" --exclude='*' "$@"
}
defn rso rsync_only
rsync_only_n() {
arg="$1"
shift
rsync-only "$arg" -n "$@"
}
defn rson rsync_only_n
defn rsp rsync-paths
defn rspc rsync-paths --clean
defn rspp rsync-paths --progress
defn rsppz rsync-paths --progress --size-only
defn rsppr rsync-paths --progress --remove-source-files
defn rsppz rsync-paths --progress --size-only
defn rspz rsync-paths --size-only
defn rsn rsync-paths -n
defn rsnc rsync-paths -n --clean
defn rsnz rsync-paths -n --size-only
defn rsnzc rsync-paths -n --size-only -- clean
defn rspr rsync-paths --remove-source-files
defn epd explode-parent-dirs
alias rsc="rsync -avzhm --progress"
alias rscr="rsync -avzhm --progress --remove-source-files"
alias rscrz="rsync -avzhm --progress --remove-source-files --size-only"
alias rscz="rsync -avzhm --progress --size-only"
alias rsr="rsync -avzhm --progress --remove-source-files"
alias rsrc="rsync -avzhm --progress --remove-source-files"
alias rscn="rsync -avzhmn"
alias rscnz="rsync -avzhmn --size-only"
rsync_include_args() {
if [ $# -lt 2 ]; then
echo "Usage: ${FUNCNAME[0]} [args...] <src> <dst>" >&2
return 1
fi
src="${@: -2:1}"
dst="${@: -1}"
set -- "${@:1:$(($#-2))}"
args=()
flags=()
clean=
for arg in "$@"; do
if [ "$arg" == --clean ]; then
clean=1
elif [ "${arg::1}" == '-' ]; then
flags+=("$arg")
else
while IFS= read -r line; do
if [[ "$line" == *\*\* ]]; then
continue
else
args+=("--include=$line")
fi
done < <(dir-tree "$arg")
args+=("--include=$arg/**")
fi
done
args+=(--include '*/')
if [ ${#args[@]} -gt 0 ]; then
args+=(--exclude '*')
fi
}
export -f rsync_include_args
rsync_clean_output() {
grep -v -e '^receiving file list' -e '^$' -e '^sent [0-9\.KM]* bytes' -e '^total size is' -e '/$'
}
export -f rsync_clean_output
defn rsco rsync_clean_output
rsync_sizes_paths() {
rsync-paths -n "--out-format=%l %n" "$@"
}
defn rsps rsync_sizes_paths
defn rspsc rsync_sizes_paths --clean
defn rspsz rsync_sizes_paths --size-only
defn rspszc rsync_sizes_paths --size-only --clean
defn rspzc rsync_sizes_paths --size-only --clean