#!/bin/sh

. scripts/functions

#
# Run a simple backup  with TLS
#   communications code enabled then restore it.
#
TestName="tls-client-initiated-connection-backup-test"
Client=connectingclient-fd
JobName=backup-connectingclient-fd

cleanup

copy_configs

# Directory to backup.
# This directory will be created by setup_data().
BackupDirectory="${tmp}/data"

# Use a tgz to setup data to be backed up.
# Data will be placed at "${tmp}/data/".
setup_data data/small.tgz

# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
echo "${BackupDirectory}" >${tmp}/file-list


start_test

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

run_bareos
check_for_zombie_jobs storage=File1 client=${Client}
stop_bareos

check_two_logs
check_restore_diff ${BackupDirectory}
end_test
