File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / testsuite / backup.test
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Wed Mar 17 00:32:36 2021 UTC (3 years, 3 months ago) by misho
Branches: rsync, MAIN
CVS tags: v3_2_3, HEAD
rsync 3.2.3

    1: #! /bin/sh
    2: 
    3: # Copyright (C) 2004-2020 Wayne Davison
    4: 
    5: # This program is distributable under the terms of the GNU GPL (see
    6: # COPYING).
    7: 
    8: # Test that the --backup option works right.
    9: 
   10: . "$suitedir/rsync.fns"
   11: 
   12: bakdir="$tmpdir/bak"
   13: 
   14: makepath "$fromdir/deep" "$bakdir/dname"
   15: name1="$fromdir/deep/name1"
   16: name2="$fromdir/deep/name2"
   17: 
   18: outfile="$scratchdir/rsync.out"
   19: 
   20: cat "$srcdir"/[gr]*.[ch] > "$name1"
   21: cat "$srcdir"/[et]*.[ch] > "$name2"
   22: 
   23: checkit "$RSYNC -ai --info=backup '$fromdir/' '$todir/'" "$fromdir" "$todir"
   24: 
   25: checkit "$RSYNC -ai --info=backup '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
   26: cat "$srcdir"/[fgpr]*.[ch] > "$name1"
   27: cat "$srcdir"/[etw]*.[ch] > "$name2"
   28: 
   29: $RSYNC -ai --info=backup --no-whole-file --backup "$fromdir/" "$todir/" \
   30:     | tee "$outfile"
   31: for fn in deep/name1 deep/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/$fn" || 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"
   36: done
   37: 
   38: echo deleted-file >"$todir/dname"
   39: cp_touch "$todir/dname" "$chkdir"
   40: 
   41: checkit "$RSYNC -ai --info=backup --no-whole-file --delete-delay \
   42:     --backup --backup-dir='$bakdir' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
   43:     | tee "$outfile"
   44: 
   45: for fn in deep/name1 deep/name2; do
   46:     grep "backed up $fn to .*/$fn$" "$outfile" >/dev/null || test_fail "no backup message output for $fn"
   47: done
   48: diff -r $diffopt "$chkdir" "$bakdir" || test_fail "backup dir contents are bogus"
   49: rm "$bakdir/dname"
   50: 
   51: checkit "$RSYNC -ai --info=backup --del '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir"
   52: cat "$srcdir"/[efgr]*.[ch] > "$name1"
   53: cat "$srcdir"/[ew]*.[ch] > "$name2"
   54: 
   55: checkit "$RSYNC -ai --info=backup --inplace --no-whole-file --backup --backup-dir='$bakdir' '$fromdir/' '$todir/'" "$fromdir" "$todir" \
   56:     | tee "$outfile"
   57: 
   58: for fn in deep/name1 deep/name2; do
   59:     grep "backed up $fn to .*/$fn$" "$outfile" >/dev/null || test_fail "no backup message output for $fn"
   60: done
   61: diff -r $diffopt "$chkdir" "$bakdir" || test_fail "backup dir contents are bogus"
   62: 
   63: checkit "$RSYNC -ai --info=backup --inplace --no-whole-file '$fromdir/' '$bakdir/'" "$fromdir" "$bakdir"
   64: 
   65: # The script would have aborted on error, so getting here means we've won.
   66: exit 0

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>