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