summaryrefslogtreecommitdiff
path: root/testsuite/backup.test
blob: 4de38674d0032f782bb98cb16b5f9be88a3b51aa (plain)
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
#!/bin/sh

# Copyright (C) 2004-2022 Wayne Davison

# This program is distributable under the terms of the GNU GPL (see
# COPYING).

# Test that the --backup option works right.

. "$suitedir/rsync.fns"

bakdir="$tmpdir/bak"

makepath "$fromdir/deep" "$bakdir/dname"
name1="$fromdir/deep/name1"
name2="$fromdir/deep/name2"

cat "$srcdir"/[gr]*.[ch] > "$name1"
cat "$srcdir"/[et]*.[ch] > "$name2"

checkit "$RSYNC -ai --info=backup '$fromdir/' '$todir/'" "$fromdir" "$todir"

checkit "$RSYNC -ai --info=backup '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
cat "$srcdir"/[fgpr]*.[ch] > "$name1"
cat "$srcdir"/[etw]*.[ch] > "$name2"

checktee "$RSYNC -ai --info=backup --no-whole-file --backup '$fromdir/' '$todir/'"
for fn in deep/name1 deep/name2; do
    grep "backed up $fn to $fn~" "$outfile" >/dev/null || test_fail "no backup message output for $fn"
    diff $diffopt "$fromdir/$fn" "$todir/$fn" || test_fail "copy of $fn failed"
    diff $diffopt "$chkdir/$fn" "$todir/$fn~" || test_fail "backup of $fn to $fn~ failed"
    mv "$todir/$fn~" "$todir/$fn"
done

echo deleted-file >"$todir/dname"
cp_touch "$todir/dname" "$chkdir"

checkit "$RSYNC -ai --info=backup --no-whole-file --delete-delay \
    --backup --backup-dir='$bakdir' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
    | tee "$outfile"

for fn in deep/name1 deep/name2; do
    grep "backed up $fn to .*/$fn$" "$outfile" >/dev/null || test_fail "no backup message output for $fn"
done
diff -r $diffopt "$chkdir" "$bakdir" || test_fail "backup dir contents are bogus"
rm "$bakdir/dname"

checkit "$RSYNC -ai --info=backup --del '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
cat "$srcdir"/[efgr]*.[ch] > "$name1"
cat "$srcdir"/[ew]*.[ch] > "$name2"

checkit "$RSYNC -ai --info=backup --inplace --no-whole-file --backup --backup-dir='$bakdir' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
    | tee "$outfile"

for fn in deep/name1 deep/name2; do
    grep "backed up $fn to .*/$fn$" "$outfile" >/dev/null || test_fail "no backup message output for $fn"
done
diff -r $diffopt "$chkdir" "$bakdir" || test_fail "backup dir contents are bogus"

checkit "$RSYNC -ai --info=backup --inplace --no-whole-file '$fromdir/' '$bakdir/'" "$fromdir" "$bakdir"

# The script would have aborted on error, so getting here means we've won.
exit 0