]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/hardlink-test
Cleanup code path for acl and count number of acl entries so we only save real acls.
[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 @# As we backup two times the same directory, the number should be 4
64 sql
65 SELECT count(1), Md5
66   FROM File JOIN Filename USING (FilenameId)
67  WHERE Name = 'hardlink-to-normalfile' OR Name = 'normalfile'
68  GROUP By Md5;
69
70 quit
71 END_OF_DATA
72
73 run_bacula
74 check_for_zombie_jobs storage=File 
75 stop_bacula
76
77 check_two_logs
78 diff ${cwd}/weird-files/subdir/another-hardlink \
79   ${cwd}/tmp/bacula-restores/${cwd}/weird-files/subdir/another-hardlink 2>&1 >/dev/null
80 dstat=$?
81
82 grep ' 0 ' $tmp/log3.out > /dev/null
83 if [ $? -eq 0 ]; then
84     print_debug "ERROR: All hardlinks should have checksums"
85     estat=1
86 fi
87
88 # if you change the file-list, adjust the number here
89 grep ' 4 ' $tmp/log4.out > /dev/null
90 if [ $? -ne 0 ]; then
91     print_debug "ERROR: All selected hardlinks should have the same checksum"
92     estat=1
93 fi
94
95 end_test