]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/hardlink-test
Make copy-job test handle one more job
[bacula/bacula] / regress / tests / hardlink-test
1 #!/bin/sh
2 #
3 # Run a simple backup of the Bacula build directory
4 #   then restore it.
5 #
6 TestName="hardlink-test"
7 JobName=hardlink
8 . scripts/functions
9
10 if test ! -d weird-files ; then
11    echo " "
12    echo "Weird files not configured. Test not run."
13    exit 0
14 fi
15
16 cwd=`pwd`
17 scripts/cleanup
18 scripts/copy-test-confs
19 change_jobname NightlySave $JobName
20 #
21 # Note, we save the weird-files directory twice on purpose
22 #  because this causes problems with hard linked files 
23 #  that are only saved once.  In 1.33, Bacula now deals
24 #  with this situation.
25 #
26 echo "${cwd}/weird-files" >${cwd}/tmp/file-list
27 echo "${cwd}/weird-files" >>${cwd}/tmp/file-list
28
29 start_test
30
31 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
32 @$out /dev/null
33 messages
34 @$out ${cwd}/tmp/log1.out
35 label storage=File
36 TestVolume001
37 setdebug level=500 client=localhost-fd trace=1
38 run job=$JobName    
39 yes
40 wait
41 messages
42 @# 
43 @# now do a restore
44 @#
45 @$out ${cwd}/tmp/log2.out
46 setdebug level=200 client=localhost-fd trace=0
47 restore where=${cwd}/tmp/bacula-restores storage=File
48 5
49 cd ${cwd}/weird-files/subdir
50 mark another-hardlink      
51 done
52 yes
53 wait
54 messages
55 @$out ${cwd}/tmp/log3.out
56 @# They should all have a MD5
57 sql
58 SELECT Name, Md5
59   FROM File JOIN Filename USING (FilenameId)
60  WHERE Name LIKE 'hard%' OR Name = 'normalfile';
61
62 @$out ${cwd}/tmp/log4.out
63 sql
64 SELECT count(1), Md5
65   FROM File JOIN Filename USING (FilenameId)
66  WHERE Name = 'hardlink-to-normalfile' 
67     OR Name = 'normalfile'
68     OR Name = 'another-hardlink-to-normalfile'
69  GROUP By Md5;
70
71 quit
72 END_OF_DATA
73
74 run_bacula
75 check_for_zombie_jobs storage=File 
76 stop_bacula
77
78 check_two_logs
79 diff ${cwd}/weird-files/subdir/another-hardlink \
80   ${cwd}/tmp/bacula-restores/${cwd}/weird-files/subdir/another-hardlink 2>&1 >/dev/null
81 dstat=$?
82
83 grep ' 0 ' $tmp/log3.out > /dev/null
84 if [ $? -eq 0 ]; then
85     print_debug "ERROR: All hardlinks should have checksums"
86     estat=1
87 fi
88
89 nb=`awk '/\| +[1-9]/ { print $0 } ' $tmp/log4.out | wc -l | sed -e 's/^ *//'`
90 if [ "$nb" != 1 ]; then
91     print_debug "ERROR: All selected hardlinks should have the same checksum"
92     estat=1
93 fi
94
95 end_test