]> arthur.barton.de Git - bup.git/blob - t/sync-tree
index: always return at least the root for filter prefixes
[bup.git] / t / sync-tree
1 #!/usr/bin/env bash
2
3 usage() {
4 cat <<EOF
5 Usage: sync-tree [-h] [-c] [-x] SOURCE/ DEST/
6   Make the DEST tree match SOURCE as closely as possible
7 OPTIONS:
8   -h
9     Display help
10 EOF
11 }
12
13 while getopts "h" OPTION
14 do
15     case "$OPTION" in
16         h) usage; exit 0;;
17         ?) usage 1>&2; exit 1;;
18     esac
19 done
20
21 shift $(($OPTIND - 1)) || exit $?
22
23 if ! test $# -eq 2
24 then
25     usage 1>&2
26     exit 1
27 fi
28
29 src="$1"
30 dest="$2"
31
32 rsync_opts="-aH --delete"
33
34 rsync_version=$(rsync --version)
35 if [[ ! "$rsync_version" =~ "ACLs" ]] || [[ "$rsync_version" =~ "no ACLs" ]]; then
36     echo "Not syncing ACLs (not supported by available rsync)" 1>&2
37 else
38     case $OSTYPE in
39         cygwin|darwin|netbsd)
40             echo "Not syncing ACLs (not yet supported on $OSTYPE)" 1>&2
41             ;;
42         *)
43             rsync_opts="$rsync_opts -A"
44             ;;
45     esac
46 fi
47
48 if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
49     echo "Not syncing xattrs (not supported by available rsync)" 1>&2
50 else
51     rsync_opts="$rsync_opts -X"
52 fi
53
54 exec rsync $rsync_opts "$src" "$dest"