#!/bin/sh
#
# Copyright (C) 2000-2026 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#

#
# Run a simple backup with encryption and no other options 
#    (i.e. no compression and no sparse handling) of the 
#    Bacula build directory.
#
TestName="data-encrypt-test"
JobName=Crypto
. scripts/functions

scripts/cleanup
scripts/copy-crypto-confs
echo "${cwd}/build" >${cwd}/tmp/file-list

change_jobname NightlySave $JobName
start_test

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

run_bacula
sleep 2
check_for_zombie_jobs storage=File 
stop_bacula

du -s build >${cwd}/tmp/log2.out
du -s ${cwd}/tmp/bacula-restores/ >${cwd}/tmp/log2.out

check_two_logs
check_restore_diff
end_test
