]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/restore-multi-session-test
Attempt to fix timing problem with console-dotcmd-test on FreeBSD
[bacula/bacula] / regress / tests / restore-multi-session-test
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # Run a two backup of the Bacula build directory + other files
7 #   then restore one file and see if we have restore problems
8 # We need a large directory to store the volume
9 # MA 1150
10 #
11 # The main goal is to have the following layout on the volume
12 #
13 # JobMedia <-----------------
14 # Job1
15 #   File1
16 #   File2
17 # Job2
18 #   File1
19 # Job1
20 #   File2
21 # JobMedia <-----------------
22 # Job1
23 #   File2
24 #
25 TestName="restore-multi-session-test"
26 JobName=backup
27 . scripts/functions
28
29 scripts/cleanup
30 scripts/copy-confs
31
32 #
33 # Zap out any schedule in default conf file so that
34 #  it doesn't start during our test
35 #
36 outf="$tmp/sed_tmp"
37 echo "s%  Schedule =%# Schedule =%g" >${outf}
38 cp $scripts/bacula-dir.conf $tmp/1
39 sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
40
41 $bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumFileSize', '500MB', 'Device')"
42 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'MaximumVolumeBytes', '10GB', 'Pool')"
43 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'Label Format', 'Vol-', 'Pool', 'Default')"
44 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'FileSet', 'FewFiles', 'Job', 'BackupClient1')"
45 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'MaximumConcurrentJobs', 10, 'Job')"
46 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'MaximumConcurrentJobs', 10, 'Client')"
47 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'MaximumConcurrentJobs', 10, 'Storage')"
48 $bperl -e "add_attribute('$conf/bacula-sd.conf',  'MaximumConcurrentJobs', 10, 'Device')"
49 $bperl -e "add_attribute('$conf/bacula-sd.conf',  'CommCompression', 'no', 'Storage')"
50 $bperl -e "add_attribute('$conf/bacula-dir.conf', 'CommCompression', 'no', 'Director')"
51 $bperl -e "add_attribute('$conf/bacula-fd.conf',  'CommCompression', 'no', 'FileDaemon')"
52 $bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumPartSize', '50MB', 'Device')"
53
54 #$bperl -e "add_attribute('$conf/bacula-dir.conf', 'SpoolData', 'Yes', 'Job', 'BackupClient1')"
55 #$bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumSpoolSize', '200MB', 'Device')"
56
57 change_jobname BackupClient1 $JobName
58 start_test
59
60 # If available, compress files on the FS, we will store only 0
61 if [ "$FORCE_CLOUD" = "" ]; then
62     touch $tmp/Vol-0001 $tmp/Vol-0002
63
64     # might not be available
65     chattr +c $tmp/Vol-0001 2> /dev/null
66     chattr +c $tmp/Vol-0002 2> /dev/null
67 fi
68
69 cat >> $conf/bacula-dir.conf <<EOF
70 FileSet {
71   Name = "FewFiles"
72   Include {
73     # start with some small files
74     File = "$cwd/build/po"
75     File = "$tmp/0.dat"
76     File = "$tmp/1.dat"
77     File = "$tmp/2.dat"
78     File = "$cwd/build/src"
79   }
80 }
81 EOF
82 director=`$bperl -e "get_dirname()"`
83
84 (
85 dd if=/dev/zero of=$tmp/0.dat count=1 obs=500M seek=1
86 dd if=/dev/zero of=$tmp/1.dat count=1 obs=500M seek=1
87 dd if=/dev/zero of=$tmp/2.dat count=1 obs=500M seek=1
88 ) 2> /dev/null
89
90 cat <<END_OF_DATA >$tmp/bconcmds
91 @$out /dev/null
92 messages
93 @$out $tmp/log1.out
94 setbandwidth limit="82400 kb/s" client
95 run job=$JobName storage=File1 level=full yes
96 @sleep 2
97 run job=$JobName storage=File1 level=full yes
98 wait
99 llist jobmedia jobid=1
100 messages
101 END_OF_DATA
102
103 run_bacula
104
105 cat <<END_OF_DATA >$tmp/bconcmds
106 @$out $tmp/log2.out  
107 @# 
108 @# now do a restore
109 @#
110 setdebug level=500 trace=1 storage=File1
111 restore where=$tmp/bacula-restores
112 3
113 1
114 cd "$tmp"
115 mark "1.dat"
116 done
117 @sleep 2
118 @exec "sh -c 'cp $working/*.restore.1.bsr $working/restore1.bsr'"
119 yes
120 wait
121 messages
122 quit
123 END_OF_DATA
124
125 run_bconsole
126
127 check_for_zombie_jobs storage=File1
128 stop_bacula
129
130 check_two_logs
131
132 cat $tmp/1.dat | md5sum > $tmp/1.dat.sum
133 cat $tmp/bacula-restores/$tmp/1.dat | md5sum > $tmp/1.dat.sum2
134
135 diff $tmp/1.dat.sum $tmp/1.dat.sum2
136 rstat=$?
137
138 end_test