summaryrefslogtreecommitdiffstats
path: root/rsync.sh
blob: 2a3605385702737c7643b6661746eb0bb248e286 (plain) (blame)
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
##
# systr_rsync_normal <src> <dst> [<link>]
#
# Perform normal rsync operations to transfer files to or from the
# repository.  If <link> is set, it is used as the --link-dest value
# for rsync.  This function is polymorphic for both local and remote
# repositories.
##
function systr_rsync_normal
{
    if [ $# -lt 2 ]; then
        echo "Fatal: too few arguments to systr_rsync_normal"
        exit 1
    fi

    src="$1"
    dst="$2"

    if [ $# -gt 2 ]; then
        link="--link-dest=$3"
    else
        link=""
    fi

    if [[ "$remote" == "" ]]; then
        rsync -az --info=progress2 --info=stats2 \
            --delete --exclude='*.systr' \
            $link \
            "$src" "$dst"
    else
        if [[ "$src" == "." ]]; then
            dst="$remote:$dst"
        else
            src="$remote:$src"
        fi

        rsync -az -e ssh --info=progress2 --info=stats2 \
            --delete --exclude='*.systr' \
            $link \
            "$src" "$dst"
    fi
}