#!/bin/bash

# this is supposed to verify that Paranoid Backup can backup, compare, and
# restore reliably.

cd /root/Paranoidbackup || exit

if
  test -e test
then
  echo "'test' already exists"
  exit
elif
  test -e all/mdti/commands
then
  echo  all/mdti/commands already exists
  exit
elif
  test ! "$1" = "--part2"
then
  testpb --part2 2>&1 | tee --append output
  exit
fi




echo =====================================================
echo test started at:
date +%c
set -e
set -x

mkdir test
echo 'include=../all/config' > test/config
echo 'DirectoryToBackup=/root/paranoidbackup' >> test/config
ln -s '../all/directory_exclude' test/directory_exclude
ln -s '../all/include_exclude' test/include_exclude
> test/virtual_restore_list

paranoidbackup.pl --check-configuration --config=test/config
echo exit code of check configuration was $?
paranoidbackup.pl --backup --verify-backup --config=test/config
echo exit code of backup was $?
paranoidbackup.pl --list --config=test/config
echo exit code of list was $?
cd test
ls -lr
cd ..
all/mdti/start &
sleep 10
cat all/mdti/index
echo -e "delete\npb_all_control.kxarc" > all/mdti/commands
sleep 5
echo -e "delete\npb_all_1.kxarc" > all/mdti/commands
sleep 5
echo exit > all/mdti/commands
rm -fr test

set +x
echo test done at:
date +%c

exit

You might think this should do a compare after it does the test backup.
But when Paranoid Backup does a backup, it automatically compares the
backup. So this does a test compare when it does a test backup.

If you have included the file 'output', then you should see an error message
saying that the file 'output' has changed. 'output' is the log of the output
of Paranoid Backup, and it is supposed to change. So if 'output' is the only
file that does not match, then Paranoid Backup is working. But if you have
excluded 'output' from backups (like I have), then you should not see any
messages saying that any files do not match.

