#!/bin/sh
#
# Run a simple backup
#   to a tape then restore it, we do that twice to ensure that
#   we can correctly append to a tape.
#
TestName="backup-win32-tape"
JobName=backupwintape
. scripts/functions

require_tape_drive_drive

scripts/cleanup-tape
scripts/copy-win32-confs

# 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

change_jobname $JobName
start_test

cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out /dev/null
messages
@$out ${cwd}/tmp/log1.out
label storage=tape volume=TestVolume001 slot=0 pool=Default
run job=NightlySave yes
@sleep 10
status storage=tape
@sleep 30
messages
wait
messages
@#
@# now do a restore
@#
@$outt ${cwd}/tmp/log2.out
@#restore where=${cwd}/tmp/bareos-restores select all storage=tape done
@#yes
@#wait
@#messages
END_OF_DATA

run_bareos
check_for_zombie_jobs storage=tape
stop_bareos

check_two_logs
check_restore_diff "$BackupDirectory"
end_test
