3 # Copyright (C) 2004 by Wayne Davison <wayned@samba.org>
5 # This program is distributable under the terms of the GNU GPL (see
8 # Test that the --backup option works right.
10 .
"$suitedir/rsync.fns"
14 mkdir
"$fromdir" "$bakdir"
15 name1
="$fromdir/name1"
16 name2
="$fromdir/name2"
18 outfile
="$scratchdir/rsync.out"
20 cat $srcdir/[gr
]*.
[ch
] > "$name1"
21 cat $srcdir/[et
]*.
[ch
] > "$name2"
23 checkit
"$RSYNC -avv \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir"
25 checkit
"$RSYNC -avv \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
26 cat $srcdir/[fgpr
]*.
[ch
] > "$name1"
27 cat $srcdir/[etw
]*.
[ch
] > "$name2"
29 $RSYNC -avv --no-whole-file --backup "$fromdir/" "$todir/" \
31 for fn
in name1 name2
; do
32 grep "backed up $fn to $fn~" "$outfile" >/dev
/null || test_fail
"no backup message output for $fn"
33 diff $diffopt "$fromdir/$fn" "$todir" || test_fail
"copy of $fn failed"
34 diff $diffopt "$chkdir/$fn" "$todir/$fn~" || test_fail
"backup of $fn to $fn~ failed"
35 mv "$todir/$fn~" "$todir/$fn"
38 echo deleted-file
>"$todir/dname"
39 cp -p "$todir/dname" "$chkdir"
41 checkit
"$RSYNC -avv --no-whole-file --delete-after \
42 --backup --backup-dir=\"$bakdir\" \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir" \
45 for fn
in name1 name2
; do
46 grep "backed up $fn to .*/$fn$" "$outfile" >/dev
/null || test_fail
"no backup message output for $fn"
48 diff -r $diffopt "$chkdir" "$bakdir" || test_fail
"backup dir contents are bogus"
51 checkit
"$RSYNC -avv --del \"$fromdir/\" \"$chkdir/\"" "$fromdir" "$chkdir"
52 cat $srcdir/[efgr
]*.
[ch
] > "$name1"
53 cat $srcdir/[ew
]*.
[ch
] > "$name2"
55 checkit
"$RSYNC -avv --inplace --no-whole-file --backup --backup-dir=\"$bakdir\" \"$fromdir/\" \"$todir/\"" "$fromdir" "$todir" \
58 for fn
in name1 name2
; do
59 grep "backed up $fn to .*/$fn$" "$outfile" >/dev
/null || test_fail
"no backup message output for $fn"
61 diff -r $diffopt "$chkdir" "$bakdir" || test_fail
"backup dir contents are bogus"
63 checkit
"$RSYNC -avv --inplace --no-whole-file \"$fromdir/\" \"$bakdir/\"" "$fromdir" "$bakdir"
65 # The script would have aborted on error, so getting here means we've won.