#!/bin/sh
#
# Run a simple backup  without
# md5 signature then restore it.
#
TestName="no-chksum-test"
JobName=backup
. scripts/functions

scripts/cleanup
scripts/copy-confs

#
# Zap out any schedule in default conf file so that
#  it doesn't start during our test
#
outf="$tmp/sed_tmp"
echo "s%  Schedule =%# Schedule =%g" > $outf
echo "s%  signature =%# signature =%g" >> $outf
cp ${conf}/bareos-dir.conf $tmp/1
sed -f $outf $tmp/1 >${conf}/bareos-dir.conf

change_jobname BackupClient1 $JobName
start_test

cat <<END_OF_DATA >$tmp/bconcmds
@$out /dev/null
messages
@$out $tmp/log1.out
label volume=TestVolume001 storage=File pool=Full
END_OF_DATA

run_bareos

cat <<END_OF_DATA >$tmp/bconcmds
@$out $tmp/log1.out
run job=$JobName yes
wait
messages
quit
END_OF_DATA

run_bconsole

#
# Now do a second backup after making a few changes
#
touch ${BackupDirectory}/fr.po
#

run_bconsole

dd if=/dev/zero of=$BackupDirectory/bigfile count=500000 > /dev/null

run_bconsole

rm -f $BackupDirectory/bigfile

cat <<END_OF_DATA >$tmp/bconcmds
@$out /dev/null
messages
@$out $tmp/log1.out
@# don't restore the bigfile, and try to see if it reads the whole volume
list files jobid=3
delete jobid=3
@#
@# now do a restore
@#
@$out $tmp/log2.out
setdebug level=150 trace=1 storage=File
restore where=$tmp/bareos-restores select all done
yes
wait
messages
quit
END_OF_DATA

run_bconsole

check_for_zombie_jobs storage=File
stop_bareos

check_two_logs
check_restore_diff
end_test
