3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # Run a basejob backup of the Bacula build directory
10 TestName="base-job-test"
16 echo 's/backup_advance/base_backup/' > $tmp/s
17 echo 's/Name = backup/Name = backup; Base = base_backup, backup/' >> $tmp/s
18 sed -f $tmp/s $rscripts/bacula-dir.conf.accurate > $conf/bacula-dir.conf
21 sed s/all,/all,saved,/ $conf/bacula-fd.conf > tmp/1
22 cp tmp/1 $conf/bacula-fd.conf
24 change_jobname BackupClient1 $JobName
27 echo "##############################################" >> ${cwd}/tmp/log1.out
28 echo "$*" >> ${cwd}/tmp/log1.out
29 echo "##############################################" >> ${cwd}/tmp/log2.out
30 echo "$*" >> ${cwd}/tmp/log2.out
34 rm -rf ${cwd}/build/accurate.new
35 rm -rf ${cwd}/build/accurate
39 mkdir ${cwd}/build/accurate
40 mkdir ${cwd}/build/accurate/dirtest
41 echo "test test" > ${cwd}/build/accurate/dirtest/hello
42 echo "test test" > ${cwd}/build/accurate/xxx
43 echo "test test" > ${cwd}/build/accurate/yyy
44 echo "test test" > ${cwd}/build/accurate/zzz
45 echo "test test" > ${cwd}/build/accurate/zzzzzz
46 echo "test test" > ${cwd}/build/accurate/xxxxxx
47 echo "test test" > ${cwd}/build/accurate/yyyyyy
48 echo "test test" > ${cwd}/build/accurate/xxxxxxxxx
49 echo "test test" > ${cwd}/build/accurate/yyyyyyyyy
50 echo "test test" > ${cwd}/build/accurate/zzzzzzzzz
51 echo ${cwd}/build > ${cwd}/tmp/file-list
55 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
58 label volume=TestVolume001 storage=File pool=Default
64 ################################################################
65 p Now do a backup using base backup
66 ################################################################
68 echo ${cwd}/bin >> ${cwd}/tmp/file-list
70 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
71 @$out ${cwd}/tmp/log1.out
72 run job=base_backup level=base yes
75 update volume=TestVolume001 volstatus=Used
80 echo ${cwd}/build > ${cwd}/tmp/file-list
82 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
83 @$out ${cwd}/tmp/log4.out
84 label volume=TestVolume002 storage=File pool=Default
85 run job=backup level=full yes
91 @$out ${cwd}/tmp/log2.out
92 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
100 check_for_zombie_jobs storage=File
105 rm -rf ${cwd}/tmp/bacula-restores
107 grep -e 'FD Bytes Written: *0' ${cwd}/tmp/log4.out > /dev/null
108 if [ $? -ne 0 ]; then
109 print_debug "ERROR: The first full job should have 0 byte in log4.out"
113 grep -e 'Using BaseJobId(s): 1$' ${cwd}/tmp/log4.out > /dev/null
114 if [ $? -ne 0 ]; then
115 print_debug "ERROR: The first full job should use only jobid=1 as basejob"
119 ################################################################
120 p Now do a backup after making few changes
121 ################################################################
122 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
123 @$out ${cwd}/tmp/log1.out
124 update volume=TestVolume002 volstatus=Used
125 label volume=TestVolume003 storage=File pool=Default
126 run job=backup level=incremental yes
133 @$out ${cwd}/tmp/log2.out
134 restore fileset=FS_TESTJOB where=${cwd}/tmp/bacula-restores select all done
140 rm ${cwd}/build/accurate/yyyyyy # delete a file
141 rm -rf ${cwd}/build/accurate/dirtest
145 check_for_zombie_jobs storage=File
149 check_files_written ${cwd}/tmp/log1.out 4
151 rm -rf ${cwd}/tmp/bacula-restores
153 ################################################################
155 ################################################################
156 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
157 @$out ${cwd}/tmp/log3.out
159 SELECT count(*) FROM BaseFiles;
161 purge volume=TestVolume002
164 SELECT count(*) FROM BaseFiles;
170 grep -e ' 0 *|' ${cwd}/tmp/log3.out > /dev/null
171 if [ $? -ne 0 ]; then
172 print_debug "ERROR: Can't purge the base job"
177 ################################################################
179 ################################################################
181 touch ${cwd}/build/po/fr.po
183 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
184 run level=full job=backup yes
187 @out ${cwd}/tmp/log5.out
188 list basefiles jobid=6
189 @out ${cwd}/tmp/log6.out
196 grep "po/fr.po^" ${cwd}/tmp/log5.out > /dev/null
197 if [ $? -eq 0 ]; then
198 print_debug "ERROR: Should not display fr.po as basefile"
202 export bstat dstat estat