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