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