]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add test to reproduce issue with checksum/accurate configuration problem
authorEric Bollengier <eric@baculasystems.com>
Tue, 12 Jul 2022 15:07:41 +0000 (17:07 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:56:58 +0000 (13:56 +0200)
regress/tests/accurate-only-meta-error-test [new file with mode: 0755]

diff --git a/regress/tests/accurate-only-meta-error-test b/regress/tests/accurate-only-meta-error-test
new file mode 100755 (executable)
index 0000000..f9cec34
--- /dev/null
@@ -0,0 +1,123 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2021 Kern Sibbald
+# Copyright (C) 2021-2022 Bacula Systems SA
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Test for the 'o' accurate backup option to backup only file's metadata
+# if file contets did not change. We test the error case after misconfiguration
+#
+
+TestName="accurate-only-meta-error-test"
+JobName=backup
+. scripts/functions
+$rscripts/cleanup
+
+copy_test_confs
+cp -f $rscripts/bacula-dir.conf.accurate $conf/bacula-dir.conf
+
+change_jobname BackupClient1 $JobName
+
+rm -f ${cwd}/build/testfile
+
+cat <<END_OF_DATA >>${conf}/bacula-dir.conf
+FileSet {
+ Name = FS_META_TEST
+ Include {
+    Options {
+      #Signature = MD5
+      #Accurate = mpin5o
+    }
+    File=<${cwd}/tmp/file-list
+ }
+}
+END_OF_DATA
+
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "FileSet", "FS_META_TEST" , "Job", "backup")'
+
+echo "${cwd}/build/po" >${cwd}/tmp/file-list
+
+rm -f ${cwd}/build/po/testfile ${cwd}/build/po/testfile.hl
+
+# Add one more file
+echo "testfile" >> ${cwd}/build/po/testfile
+
+start_test
+
+# Run normal backup
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out /dev/null
+messages
+label volume=TestVolume001 storage=File pool=Default
+messages
+@$out ${cwd}/tmp/log1.out
+setdebug trace=1 level=0 client
+run job=$JobName yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+
+# Change some properties of testfile
+chmod 740 ${cwd}/build/po/testfile
+perm_after=`$bperl -e "get_perm('${cwd}/build/po/testfile')"`
+
+sed 's/#Signature/Signature/' $conf/bacula-dir.conf | sed 's/#Accurate/Accurate/'  > $tmp/1
+mv $tmp/1 $conf/bacula-dir.conf
+
+
+# Run backup for the second time, this time we expect that only metadata part for each file will be
+# backed up, so we expect the backup size to be much smaller than the first one.
+# Do the restore after that and check if metadata is updated (meaning if second backup overwritten files's metadata)
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out ${cwd}/tmp/log3.out
+reload
+run job=$JobName yes
+wait
+messages
+list files type=deleted jobid=2
+list files jobid=2
+@$out ${cwd}/tmp/log2.out
+restore where=$tmp/bacula-restores2 select all done yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+$rscripts/diff.pl -s $cwd/build/po/ -d $tmp/bacula-restores2/$cwd/build/po/
+if [ $? -ne 0 ]; then
+    print_debug "ERROR: Found  difference after restore"
+    rstat=1
+fi
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@exec "touch $cwd/build/po/testfile"
+@$out ${cwd}/tmp/log3.out
+run job=$JobName yes
+wait
+messages
+list files type=all jobid=3
+@$out ${cwd}/tmp/log2.out
+restore select all done yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+$rscripts/diff.pl -s $cwd/build/po/ -d $tmp/bacula-restores/$cwd/build/po/
+if [ $? -ne 0 ]; then
+    print_debug "ERROR: Found  difference after restore"
+    rstat=1
+fi
+
+# Cleanup
+rm -f ${cwd}/build/po/testfile ${cwd}/build/po/testfile.hl
+
+stop_bacula
+end_test