#!/bin/sh
#
# Run a simple backup then restore it.
#
TestName="weird-files-test"
JobName=weird-files
. scripts/functions

if test ! -d weird-files ; then
   echo " "
   echo "weird files not configured. Test not run."
   exit 0
fi

scripts/cleanup
scripts/copy-test-confs
change_jobname NightlySave $JobName
#
# Note, we save the weird-files directory twice on purpose
#  because this causes problems with hard linked files
#  that are only saved once.
#
echo "${cwd}/weird-files" >${cwd}/tmp/file-list
echo "${cwd}/weird-files" >>${cwd}/tmp/file-list

# Create a Unix domain socket (sock-file)
cd weird-files
perl socket.pl
cd ..

start_test

cat <<END_OF_DATA >tmp/bconcmds
@$out /dev/null
messages
@$out tmp/log1.out
label storage=File volume=TestVolume001
run job=$JobName yes
wait
messages
@#
@# now do a restore
@#
@$out tmp/log2.out
restore where=${cwd}/tmp/bareos-restores select storage=File
unmark *
mark *
done
yes
wait
messages
quit
END_OF_DATA

run_bareos
check_for_zombie_jobs storage=File
stop_bareos

check_two_logs

# use only diff.pl here, because normal diff can't handle some of the files properly.
$rscripts/diff.pl -s ${cwd}/weird-files -d ${tmp}/bareos-restores/${cwd}/weird-files
dstat=$?

end_test
