# EXAMPLES
# make a backup in case things go horribly wrong
- cp -a ~/.bup/objects/pack ~/bup-packs.bak
+ cp -pPR ~/.bup/objects/pack ~/bup-packs.bak
# generate recovery blocks for all packs
bup fsck -g
ln -sf b c || exit $?
ln -sf "$(pwd)/abs-symlink-target" abs-symlink || exit $?
mkdir -p cmd doc lib/bup || exit $?
- cp -a "$top"/cmd/*.py cmd/ || exit $?
- cp -a "$top"/Documentation/*.md doc/ || exit $?
- cp -a "$top"/lib/bup/*.py lib/bup || exit $?
+ cp -pP "$top"/cmd/*.py cmd/ || exit $?
+ cp -pP "$top"/Documentation/*.md doc/ || exit $?
+ cp -pP "$top"/lib/bup/*.py lib/bup || exit $?
# The "v" ensures that if "configure-sampledata
# --revision" and/or the setup above fails somehow,
# callers like make will be looking for a file that won't
--- /dev/null
+#!/usr/bin/env bash
+
+usage() {
+cat <<EOF
+Usage: sync-tree [-h] [-c] [-x] SOURCE/ DEST/
+ Make the DEST tree match SOURCE as closely as possible
+OPTIONS:
+ -h
+ Display help
+EOF
+}
+
+while getopts "h" OPTION
+do
+ case "$OPTION" in
+ h) usage; exit 0;;
+ ?) usage 1>&2; exit 1;;
+ esac
+done
+
+shift $(($OPTIND - 1)) || exit $?
+
+if ! test $# -eq 2
+then
+ usage 1>&2
+ exit 1
+fi
+
+src="$1"
+dest="$2"
+
+rsync_opts="-aH --delete"
+
+rsync_version=$(rsync --version)
+if [[ ! "$rsync_version" =~ "ACLs" ]] || [[ "$rsync_version" =~ "no ACLs" ]]; then
+ echo "Not syncing ACLs (not supported by available rsync)" 1>&2
+else
+ case $OSTYPE in
+ cygwin|darwin|netbsd)
+ echo "Not syncing ACLs (not yet supported on $OSTYPE)" 1>&2
+ ;;
+ *)
+ rsync_opts="$rsync_opts -A"
+ ;;
+ esac
+fi
+
+if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
+ echo "Not syncing xattrs (not supported by available rsync)" 1>&2
+else
+ rsync_opts="$rsync_opts -X"
+fi
+
+exec rsync $rsync_opts "$src" "$dest"
bup() { "$top/bup" "$@"; }
-WVPASS cp -a "$top/t/sampledata" "$tmpdir/src"
+WVPASS "$top/t/sync-tree" "$top/t/sampledata/" "$tmpdir/src/"
export BUP_DIR="$tmpdir/bup"
export GIT_DIR="$tmpdir/bup"
dup() { duplicity --archive-dir "$tmpdir/dup-cache" "$@"; }
WVSTART "import-duplicity"
-WVPASS cp -a "$top/t/sampledata" "$tmpdir/src"
+WVPASS "$top/t/sync-tree" "$top/t/sampledata/" "$tmpdir/src/"
export BUP_DIR="$tmpdir/bup"
export GIT_DIR="$tmpdir/bup"
setup-test-tree()
{
- WVPASS cp -a "$TOP/t/sampledata" "$tmpdir/src"
+ WVPASS "$TOP/t/sync-tree" "$TOP/t/sampledata/" "$tmpdir/src/"
# Add some hard links for the general tests.
(
WVPASS "$TOP/t/compare-trees" -c src/ src-restore-1/src/
WVPASS echo "blarg" > src/volatile/1
- WVPASS cp -a src/volatile/1 src-restore-1/src/volatile/
+ WVPASS cp -pP src/volatile/1 src-restore-1/src/volatile/
WVPASS bup index src
# Bup should *not* pick up these metadata changes.