1#!/bin/sh
2#
3# Run a simple backup using the compressed option
4#   then backup four times, each with incremental then
5#   do a bscan and restore.
6#   It should require at least 4 different bsrs.
7#
8
9TestName="bscan-tape"
10JobName=bscantape
11. scripts/functions
12
13require_tape_drive
14
15copy_tape_confs
16
17change_jobname NightlySave $JobName
18
19
20# Directory to backup.
21# This directory will be created by setup_data().
22BackupDirectory="${tmp}/data"
23
24# Use a tgz to setup data to be backuped.
25# Data will be placed at "${tmp}/data/".
26setup_data data/small.tgz
27
28echo "${BackupDirectory}" >${tmp}/file-list
29
30cp ${conf}/bareos-sd.conf tmp/1
31sed "s%# Maximum File Size%  Maximum File Size%" tmp/1 >${conf}/bareos-sd.conf
32
33start_test
34
35cat <<END_OF_DATA >tmp/bconcmds
36@$out tmp/log1.out
37setdebug level=2 storage=tape
38label storage=tape volume=TestVolume001 slot=0 pool=Default
39run job=$JobName level=Full yes
40wait
41run job=$JobName level=Full yes
42wait
43messages
44quit
45END_OF_DATA
46
47run_bareos
48check_for_zombie_jobs storage=tape
49
50echo "Backup 1 done"
51# make some files for the incremental to pick up
52echo "test test" > ${BackupDirectory}/additional2.txt
53
54#
55# run a second job
56#
57cat <<END_OF_DATA >tmp/bconcmds
58@$out /dev/null
59messages
60@$out tmp/log1.out
61run job=$JobName level=Incremental yes
62wait
63messages
64quit
65END_OF_DATA
66
67run_bconsole
68scripts/check_for_zombie_jobs storage=tape
69
70echo "Backup 2 done"
71echo "test test" > ${BackupDirectory}/additional3.txt
72
73#
74# run a third job
75#
76run_bconsole
77scripts/check_for_zombie_jobs storage=tape
78
79echo "Backup 3 done"
80# make some files for the incremental to pick up
81echo "test test" > ${BackupDirectory}/additional4.txt
82
83#
84# run a fourth job
85#
86run_bconsole
87scripts/check_for_zombie_jobs storage=tape
88
89stop_bareos
90
91echo "Backup 4 done"
92#
93# now drop and recreate the database
94#
95${scripts}/drop_bareos_tables >/dev/null 2>&1
96${scripts}/make_bareos_tables >/dev/null 2>&1
97${scripts}/grant_bareos_privileges >/dev/null 2>&1
98
99echo "volume=TestVolume001" >tmp/bscan.bsr
100
101bscan_libdbi
102
103# If the database has a password pass it to bscan
104if test "x${db_password}" = "x"; then
105  PASSWD=
106else
107  PASSWD="-P ${db_password}"
108fi
109
110BSCAN_OUT="write_stdin_to_file ${tmp}/log-bscan.out"
111if is_debug; then
112   BSCAN_OUT="tee ${tmp}/log-bscan.out"
113fi
114
115$bin/bscan -c ${conf} $BSCANLIBDBI -B ${DBTYPE} -n ${db_name} -u ${db_user} $PASSWD -m -s -v -b $tmp/bscan.bsr tape 2>&1 | $BSCAN_OUT
116
117
118
119cat <<END_OF_DATA >tmp/bconcmds
120@$out /dev/null
121messages
122@$out tmp/log2.out
123@#
124@# now do a restore
125@#
126restore where=${cwd}/tmp/bareos-restores select all storage=tape done
127yes
128wait
129messages
130quit
131END_OF_DATA
132
133run_bareos
134check_for_zombie_jobs storage=tape
135stop_bareos
136
137check_two_logs
138check_restore_diff ${BackupDirectory}
139end_test
140
141