mirror of
https://github.com/usatiuk/backup.git
synced 2025-10-26 17:37:47 +01:00
proper cmake
This commit is contained in:
294
tests/clitests/scripts/backup.sh
Executable file
294
tests/clitests/scripts/backup.sh
Executable file
@@ -0,0 +1,294 @@
|
||||
#!/bin/bash
|
||||
|
||||
TESTSIZE=16
|
||||
|
||||
# TODO: Don't hardcode this
|
||||
CMD="../../src/backup"
|
||||
|
||||
rm -rf testdata
|
||||
rm -rf testdir
|
||||
|
||||
mkdir -p testdir
|
||||
mkdir -p testdata/1
|
||||
mkdir -p testdata/1/empty
|
||||
mkdir -p testdata/1/notempty
|
||||
echo "testtestasdf" > testdata/1/notempty/testfile
|
||||
|
||||
|
||||
dd if=/dev/urandom of=testdata/1/a bs=1M count=$TESTSIZE
|
||||
dd if=/dev/urandom of=testdata/1/b bs=1M count=$TESTSIZE
|
||||
dd if=/dev/urandom of=testdata/1/c bs=1M count=$TESTSIZE
|
||||
|
||||
ln -s a testdata/1/l
|
||||
ln -s aa testdata/1/aa
|
||||
|
||||
cp -a -p testdata/1 testdata/2
|
||||
echo "asdf1" > testdata/2/c
|
||||
cat testdata/1/c >> testdata/2/c
|
||||
|
||||
sleep 1
|
||||
|
||||
cp -a -p testdata/2 testdata/3
|
||||
echo "asdf2" > testdata/3/a
|
||||
cat testdata/2/a >> testdata/3/a
|
||||
rm testdata/3/l
|
||||
ln -s b testdata/3/l
|
||||
|
||||
cp -a -p testdata/3 testdata/4
|
||||
echo "asdf3" > testdata/4/b
|
||||
cat testdata/3/b >> testdata/4/b
|
||||
|
||||
cp -a -p testdata/1 testdata/5
|
||||
cp -a -p testdata/1 testdata/6
|
||||
rm testdata/6/a
|
||||
cp -a -p testdata/1 testdata/7
|
||||
|
||||
cp -a -p testdata/7 testdata/8
|
||||
echo "asdf3" > testdata/8/b
|
||||
cat testdata/7/b >> testdata/8/b
|
||||
|
||||
echo "Data created"
|
||||
|
||||
if ! $CMD init --repo testdir/to1 --compression zlib --compression-level 4 --encryption aes --password asdff --salt e --full-period 999; then
|
||||
echo "Error creating repo!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Repo created"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Copied: a' ) && ( echo "$OUT" | grep -q 'Copied: aa' ) && ( echo "$OUT" | grep -q 'Copied: b' ) && ( echo "$OUT" | grep -q 'Copied: c' ) ); then
|
||||
echo "Error backing up 1 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 1 ok"
|
||||
OUT=$($CMD run --from testdata/2 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Skipped: a' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) &&\
|
||||
( echo "$OUT" | grep -q 'Skipped: empty' ) && ( echo "$OUT" | grep -q 'Skipped: l' ) && ( echo "$OUT" | grep -q 'Skipped: notempty' ) && ( echo "$OUT" | grep -q 'Copied: c' ) ); then
|
||||
echo "Error backing up 2 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 2 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/3 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Copied: a' ) && ( echo "$OUT" | grep -q 'Copied: l' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) &&\
|
||||
( echo "$OUT" | grep -q 'Skipped: empty' ) && ( echo "$OUT" | grep -q 'Skipped: notempty' ) && ( echo "$OUT" | grep -q 'Skipped: c' ) ); then
|
||||
echo "$OUT"
|
||||
echo "Error backing up 3 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 3 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/4 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Skipped: a' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) && ( echo "$OUT" | grep -q 'Copied: b' ) && ( echo "$OUT" | grep -q 'Skipped: c' ) ); then
|
||||
echo "Error backing up 4 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 4 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/5 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Copied: a' ) && ( echo "$OUT" | grep -q 'Copied: b' ) && ( echo "$OUT" | grep -q 'Copied: c' ) ); then
|
||||
echo "Error backing up 5 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 5 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/6 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'Copied: a' ) && ! ( echo "$OUT" | grep -q 'Skipped: a ' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) && ( echo "$OUT" | grep -q 'Skipped: c' ) ); then
|
||||
echo "Error backing up 6 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 6 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/7 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Copied: a' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) && ( echo "$OUT" | grep -q 'Skipped: c' ) ); then
|
||||
echo "Error backing up 7 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 7 ok"
|
||||
|
||||
|
||||
|
||||
i=$((0))
|
||||
AIDS=()
|
||||
OUT=$($CMD list --repo testdir/to1 --password asdff)
|
||||
echo "$OUT"
|
||||
|
||||
while IFS= read -r l; do
|
||||
((i++))
|
||||
aid=$(echo $l | grep -Eo '[0-9]+' | tail -1)
|
||||
AIDS+=("$aid")
|
||||
$CMD restore --repo testdir/to1 --password asdff --aid $aid --to testdir/res$((i))
|
||||
if ! diff --no-dereference -r testdata/$((i)) testdir/res$((i)); then
|
||||
echo "Archive not restored properly!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Restore $((i)) OK"
|
||||
done <<< "$OUT"
|
||||
|
||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[0]} --aid2 ${AIDS[1]})
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'c is different' ) && ! ( echo "$OUT" | grep -q 'a is different' ) && ! ( echo "$OUT" | grep -q 'l is different' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'aa is different' ) && ! ( echo "$OUT" | grep -q 'b is different' ) && ! ( echo "$OUT" | grep -q 'empty is different' ) && ! ( echo "$OUT" | grep -q 'notempty is different' ) ); then
|
||||
echo "Error comparing archive 1 and 2!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 1 and 2"
|
||||
|
||||
|
||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[1]} --aid2 ${AIDS[2]})
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'a is different' ) && ( echo "$OUT" | grep -q 'l is different' ) && ! ( echo "$OUT" | grep -q 'c is different' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'b is different' ) && ! ( echo "$OUT" | grep -q 'empty is different' ) && ! ( echo "$OUT" | grep -q 'notempty is different' ) ); then
|
||||
echo "Error comparing archive 2 and 3!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 2 and 3"
|
||||
|
||||
OUT=$($CMD diff --diff-mode file --from testdata/4 --prefix a --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[1]} --aid2 ${AIDS[2]})
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'a is different' ) && ! ( echo "$OUT" | grep -q 'l is different' ) ); then
|
||||
echo "Error comparing archive 2 and 3! (file 1)"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 2 and 3 (file 1)"
|
||||
|
||||
OUT=$($CMD diff --diff-mode file --from testdata/4 --prefix l --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[1]} --aid2 ${AIDS[2]})
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'a is different' ) && ( echo "$OUT" | grep -q 'l is different' ) ); then
|
||||
echo "Error comparing archive 2 and 3! (file 2)"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 2 and 3 (file 2)"
|
||||
|
||||
OUT=$($CMD diff --diff-mode file --from testdata/4 --prefix b --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[1]} --aid2 ${AIDS[2]})
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'a is different' ) && ! ( echo "$OUT" | grep -q 'l is different' ) && ( echo "$OUT" | grep -q 'b are same' ) ); then
|
||||
echo "Error comparing archive 2 and 3! (file 3)"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 2 and 3 (file 3)"
|
||||
|
||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[2]})
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'b is different' ) && ! ( echo "$OUT" | grep -q 'a is different' ) && ! ( echo "$OUT" | grep -q 'l is different' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'aa is different' ) && ! ( echo "$OUT" | grep -q 'c is different' ) && ! ( echo "$OUT" | grep -q 'empty is different' ) && ! ( echo "$OUT" | grep -q 'notempty is different' ) ); then
|
||||
echo "Error comparing archive 3 and current!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 3 and current"
|
||||
|
||||
OUT=$($CMD diff --from testdata/3 --repo testdir/to1 --password asdff --progress none --verbose 1 )
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'b is different' ) && ( echo "$OUT" | grep -q 'a is different' ) && ( echo "$OUT" | grep -q 'l is different' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'aa is different' ) && ( echo "$OUT" | grep -q 'c is different' ) && ! ( echo "$OUT" | grep -q 'empty is different' ) && ! ( echo "$OUT" | grep -q 'notempty is different' ) ); then
|
||||
echo "Error comparing archive last and current!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive last and current"
|
||||
|
||||
|
||||
if ! $CMD init --repo testdir/to2 --compression zlib --compression-level 4 --encryption aes --password asdff --salt e; then
|
||||
echo "Error creating repo!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Repo created"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( (echo "$OUT" | grep -q 'Backup is full because there are no backups')&&( echo "$OUT" | grep -q 'Copied: a' ) && ( echo "$OUT" | grep -q 'Copied: aa' ) && ( echo "$OUT" | grep -q 'Copied: b' ) && ( echo "$OUT" | grep -q 'Copied: c' ) ); then
|
||||
echo "Error backing up 1 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 1 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'Backup is full' ) && ( echo "$OUT" | grep -q 'Skipped: a' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) && ( echo "$OUT" | grep -q 'Skipped: c' )); then
|
||||
echo "Error backing up 2 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 2 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'Backup is full' )&& ( echo "$OUT" | grep -q 'Skipped: a' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) && ( echo "$OUT" | grep -q 'Skipped: c' ) ); then
|
||||
echo "Error backing up 3 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 3 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Backup is full because of the interval') &&( echo "$OUT" | grep -q 'Copied: a' ) && ( echo "$OUT" | grep -q 'Copied: aa' ) && ( echo "$OUT" | grep -q 'Copied: b' ) && ( echo "$OUT" | grep -q 'Copied: c' )); then
|
||||
echo "Error backing up 4 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 4 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'Backup is full' ) && ( echo "$OUT" | grep -q 'Skipped: a' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) && ( echo "$OUT" | grep -q 'Skipped: c' ) ); then
|
||||
echo "Error backing up 5 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 5 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'Backup is full' ) && ( echo "$OUT" | grep -q 'Skipped: a' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) && ( echo "$OUT" | grep -q 'Skipped: c' ) ); then
|
||||
echo "Error backing up 6 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 6 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Backup is full because of the interval' ) &&( echo "$OUT" | grep -q 'Copied: a' ) && ( echo "$OUT" | grep -q 'Copied: aa' ) && ( echo "$OUT" | grep -q 'Copied: b' ) && ( echo "$OUT" | grep -q 'Copied: c' ) ); then
|
||||
echo "Error backing up 7 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 7 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1 --type full)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Backup is full because of the config') &&( echo "$OUT" | grep -q 'Copied: a' ) && ( echo "$OUT" | grep -q 'Copied: aa' ) && ( echo "$OUT" | grep -q 'Copied: b' ) && ( echo "$OUT" | grep -q 'Copied: c' )); then
|
||||
echo "Error backing up 8 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 8 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'Backup is full' ) && ( echo "$OUT" | grep -q 'Skipped: a' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) && ( echo "$OUT" | grep -q 'Skipped: c' ) ); then
|
||||
echo "Error backing up 9 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 9 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'Backup is full' ) && ( echo "$OUT" | grep -q 'Skipped: a' ) && ( echo "$OUT" | grep -q 'Skipped: aa' ) && ( echo "$OUT" | grep -q 'Skipped: b' ) && ( echo "$OUT" | grep -q 'Skipped: c' ) ); then
|
||||
echo "Error backing up 10 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 10 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to2 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Backup is full because of the interval' ) &&( echo "$OUT" | grep -q 'Copied: a' ) && ( echo "$OUT" | grep -q 'Copied: aa' ) && ( echo "$OUT" | grep -q 'Copied: b' ) && ( echo "$OUT" | grep -q 'Copied: c' ) ); then
|
||||
echo "Error backing up 11 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 11 ok"
|
||||
|
||||
rm -rf testdata
|
||||
rm -rf testdir
|
||||
|
||||
exit 0
|
||||
183
tests/clitests/scripts/diff.sh
Executable file
183
tests/clitests/scripts/diff.sh
Executable file
@@ -0,0 +1,183 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: Don't hardcode this
|
||||
CMD="../../src/backup"
|
||||
|
||||
rm -rf testdata
|
||||
rm -rf testdir
|
||||
|
||||
mkdir -p testdir
|
||||
mkdir -p testdata/1
|
||||
mkdir -p testdata/1/empty
|
||||
mkdir -p testdata/1/notempty
|
||||
|
||||
mkdir -p testdata/1/emptyi
|
||||
mkdir -p testdata/1/notemptyi
|
||||
|
||||
mkdir -p testdata/1/notempty2/empty
|
||||
mkdir -p testdata/1/notempty2/notemptyi2
|
||||
mkdir -p testdata/1/notempty2/notemptyi2/ignoredir
|
||||
|
||||
echo "testtestasdf1" > testdata/1/notempty/testfile
|
||||
echo "testtestasdf2" > testdata/1/notemptyi/testfile
|
||||
echo "testtestasdf3" > testdata/1/notempty2/notempty
|
||||
echo "testtestasdf4" > testdata/1/notempty2/notemptyi2/test4
|
||||
echo "testtestasdf5" > testdata/1/notempty2/notemptyi2/test5
|
||||
echo "testtestasdf6" > testdata/1/notempty2/notemptyi2/test6
|
||||
echo "testtestasdf7" > testdata/1/notempty2/notemptyi2/test7
|
||||
echo "testtestasdf8" > testdata/1/notempty2/notemptyi2/ignoredir/testa
|
||||
echo "testtestasdf9" > testdata/1/filexd
|
||||
|
||||
echo ".*4" > testdata/1/notempty2/.ignore
|
||||
echo ".*5" > testdata/1/notempty2/notemptyi2/.ignore
|
||||
touch testdata/1/notemptyi/.nobackup
|
||||
touch testdata/1/emptyi/.nobackup
|
||||
touch testdata/1/notempty2/notemptyi2/ignoredir/.nobackup
|
||||
|
||||
cp -a -p testdata/1 testdata/2
|
||||
echo "testtestasdf4u" > testdata/2/notempty2/notemptyi2/test4
|
||||
echo "testtestasdf5u" > testdata/2/notempty2/notemptyi2/test5
|
||||
echo "testtestasdf6u" > testdata/2/notempty2/notemptyi2/test6
|
||||
echo "testtestasdf7u" > testdata/2/notempty2/notemptyi2/test7
|
||||
echo "testtestasdf8u" > testdata/2/notempty2/notemptyi2/ignoredir/testa
|
||||
echo "testtestasdf9u" > testdata/2/filexd
|
||||
|
||||
cp -a -p testdata/2 testdata/3
|
||||
echo "testtestasdf4uu" > testdata/3/notempty2/notemptyi2/test4
|
||||
echo "testtestasdf5uu" > testdata/3/notempty2/notemptyi2/test5
|
||||
echo "testtestasdf6uu" > testdata/3/notempty2/notemptyi2/test6
|
||||
echo "testtestasdf7uu" > testdata/3/notempty2/notemptyi2/test7
|
||||
echo "testtestasdf8uu" > testdata/3/notempty2/notemptyi2/ignoredir/testa
|
||||
echo "testtestasdf9uu" > testdata/3/filexd
|
||||
|
||||
cp -a -p testdata/2 testdata/4
|
||||
echo "testtestasdf4uuu" > testdata/4/notempty2/notemptyi2/test4
|
||||
echo "testtestasdf5uuu" > testdata/4/notempty2/notemptyi2/test5
|
||||
echo "testtestasdf6uuu" > testdata/4/notempty2/notemptyi2/test6
|
||||
echo "testtestasdf7uuu" > testdata/4/notempty2/notemptyi2/test7
|
||||
echo "testtestasdf8uuu" > testdata/4/notempty2/notemptyi2/ignoredir/testa
|
||||
echo "testtestasdf9uuu" > testdata/4/filexd
|
||||
|
||||
echo "Data created"
|
||||
|
||||
if ! $CMD init --repo testdir/to1 --compression zlib --compression-level 4 --encryption aes --password asdff --salt e --full-period 999; then
|
||||
echo "Error creating repo!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Repo created"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Copied: notempty/testfile' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notempty' ) \
|
||||
&& ( echo "$OUT" | grep -q 'Copied: filexd' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notemptyi ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'emptyi ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notemptyi/testfile' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notemptyi2/ignoredir/testa' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notemptyi2/test6' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notemptyi2/test7' ) ); then
|
||||
echo "Error backing up 1 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 1 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/2 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notemptyi2/ignoredir/testa ' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: filexd' ) \
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notemptyi2/test6' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notemptyi2/test7' ) ); then
|
||||
echo "Error backing up 2 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 2 ok"
|
||||
|
||||
OUT=$($CMD run --from testdata/3 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notemptyi2/ignoredir/testa ' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: filexd' ) \
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notemptyi2/test6' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notemptyi2/test7' ) ); then
|
||||
echo "Error backing up 3 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 3 ok"
|
||||
|
||||
|
||||
i=$((0))
|
||||
AIDS=()
|
||||
OUT=$($CMD list --repo testdir/to1 --password asdff)
|
||||
echo "$OUT"
|
||||
while IFS= read -r l; do
|
||||
((i++))
|
||||
aid=$(echo $l | grep -Eo '[0-9]+' | tail -1)
|
||||
AIDS+=("$aid")
|
||||
done <<< "$OUT"
|
||||
|
||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[0]} --aid2 ${AIDS[1]})
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test6 is different' ) && ( echo "$OUT" | grep -q 'filexd is different' ) && ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test7 is different' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4' ) && ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5' ) && ! ( echo "$OUT" | grep -q 'notemptyi2/ignoredir/testa' ) ); then
|
||||
echo "Error comparing archive 1 and 2!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 1 and 2"
|
||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[1]} --aid2 ${AIDS[2]})
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test6 is different' ) && ( echo "$OUT" | grep -q 'filexd is different' ) && ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test7 is different' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4' ) && ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5' ) && ! ( echo "$OUT" | grep -q 'notemptyi2/ignoredir/testa' ) ); then
|
||||
echo "Error comparing archive 2 and 3!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 2 and 3"
|
||||
|
||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[2]})
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test6 is different' ) && ( echo "$OUT" | grep -q 'filexd is different' ) && ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test7 is different' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4' ) && ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5' ) && ! ( echo "$OUT" | grep -q 'notemptyi2/ignoredir/testa' ) ); then
|
||||
echo "Error comparing archive 3 and current!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 3 and current"
|
||||
|
||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 )
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test6 is different' ) && ( echo "$OUT" | grep -q 'filexd is different' ) && ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test7 is different' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4' ) && ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5' ) && ! ( echo "$OUT" | grep -q 'notemptyi2/ignoredir/testa' ) ); then
|
||||
echo "Error comparing archive last (3) and current!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive last (3) and current"
|
||||
|
||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[2]} --prefix notempty2/notemptyi2 )
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test6 is different' ) && ! ( echo "$OUT" | grep -q 'filexd is different' ) && ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test7 is different' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4' ) && ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5' ) && ! ( echo "$OUT" | grep -q 'notemptyi2/ignoredir/testa' ) ); then
|
||||
echo "Error comparing archive 3 and current!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive 3 and current with prefix "
|
||||
|
||||
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --prefix notempty2/notemptyi2 )
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test6 is different' ) && ! ( echo "$OUT" | grep -q 'filexd is different' ) && ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test7 is different' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4' ) && ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5' ) && ! ( echo "$OUT" | grep -q 'notemptyi2/ignoredir/testa' ) ); then
|
||||
echo "Error comparing archive last (3) and current!"
|
||||
exit 1
|
||||
fi
|
||||
echo "OK comparing archive last (3) and current with prefix "
|
||||
|
||||
|
||||
rm -rf testdata
|
||||
rm -rf testdir
|
||||
|
||||
exit 0
|
||||
90
tests/clitests/scripts/ignore.sh
Executable file
90
tests/clitests/scripts/ignore.sh
Executable file
@@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
# TODO: Don't hardcode this
|
||||
CMD="../../src/backup"
|
||||
|
||||
rm -rf testdata
|
||||
rm -rf testdir
|
||||
|
||||
mkdir -p testdir
|
||||
mkdir -p testdata/1
|
||||
mkdir -p testdata/1/empty
|
||||
mkdir -p testdata/1/notempty
|
||||
|
||||
mkdir -p testdata/1/emptyi
|
||||
mkdir -p testdata/1/notemptyi
|
||||
|
||||
mkdir -p testdata/1/notempty2/empty
|
||||
mkdir -p testdata/1/notempty2/notemptyi2
|
||||
|
||||
echo "testtestasdf1" > testdata/1/notempty/testfile
|
||||
echo "testtestasdf2" > testdata/1/notemptyi/testfile
|
||||
echo "testtestasdf3" > testdata/1/notempty2/notempty
|
||||
echo "testtestasdf4" > testdata/1/notempty2/notemptyi2/test4
|
||||
echo "testtestasdf5" > testdata/1/notempty2/notemptyi2/test5
|
||||
echo "testtestasdf6" > testdata/1/notempty2/notemptyi2/test6
|
||||
echo "testtestasdf7" > testdata/1/notempty2/notemptyi2/test7
|
||||
|
||||
echo ".*4" > testdata/1/notempty2/.ignore
|
||||
echo ".*5" > testdata/1/notempty2/notemptyi2/.ignore
|
||||
touch testdata/1/notemptyi/.nobackup
|
||||
touch testdata/1/emptyi/.nobackup
|
||||
|
||||
echo "Data created"
|
||||
|
||||
if ! $CMD init --repo testdir/to1 --compression zlib --compression-level 4 --encryption aes --password asdff --salt e --full-period 999; then
|
||||
echo "Error creating repo!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Repo created"
|
||||
|
||||
OUT=$($CMD run --from testdata/1 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q 'Copied: notempty/testfile' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notempty' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notemptyi ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'emptyi ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notemptyi/testfile' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notemptyi2/test6' )\
|
||||
&& ( echo "$OUT" | grep -q 'Copied: notempty2/notemptyi2/test7' ) ); then
|
||||
echo "Error backing up 1 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "Backup 1 ok"
|
||||
|
||||
i=$((0))
|
||||
AIDS=()
|
||||
OUT=$($CMD list --repo testdir/to1 --password asdff)
|
||||
echo "$OUT"
|
||||
while IFS= read -r l; do
|
||||
((i++))
|
||||
aid=$(echo $l | grep -Eo '[0-9]+' | tail -1)
|
||||
AIDS+=("$aid")
|
||||
done <<< "$OUT"
|
||||
|
||||
OUT=$($CMD list-files --aid ${AIDS[0]} --from testdata/1 --repo testdir/to1 --password asdff --progress simple --verbose 1)
|
||||
echo "$OUT"
|
||||
if ! ( ( echo "$OUT" | grep -q ' notempty/testfile' )\
|
||||
&& ( echo "$OUT" | grep -q ' notempty' )\
|
||||
&& ( echo "$OUT" | grep -q ' notempty2' )\
|
||||
&& ( echo "$OUT" | grep -q ' notempty2/notempty' ) \
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test4 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notempty2/notemptyi2/test5 ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notemptyi ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'emptyi ' )\
|
||||
&& ! ( echo "$OUT" | grep -q 'notemptyi/testfile' )\
|
||||
&& ( echo "$OUT" | grep -q ' notempty2/notemptyi2/test6' )\
|
||||
&& ( echo "$OUT" | grep -q ' notempty2/notemptyi2/test7' ) ); then
|
||||
echo "Error listing 1 dir!"
|
||||
exit 1
|
||||
fi
|
||||
echo "List 1 ok"
|
||||
|
||||
rm -rf testdata
|
||||
rm -rf testdir
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user