]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
BEE Backport regress/tests/restore-multi-version-test
authorEric Bollengier <eric@baculasystems.com>
Wed, 2 Sep 2020 13:32:27 +0000 (15:32 +0200)
committerEric Bollengier <eric@baculasystems.com>
Tue, 1 Mar 2022 14:36:18 +0000 (15:36 +0100)
This commit is the result of the squash of the following main commits:

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Jul 21 10:28:13 2020 +0200

    regress: Add copyright to regress scripts

Author: Eric Bollengier <eric@baculasystems.com>
Date:   Tue Aug 14 16:37:14 2018 +0200

    regress: Add test for the $m regexwhere option

regress/tests/restore-multi-version-test [new file with mode: 0755]

diff --git a/regress/tests/restore-multi-version-test b/regress/tests/restore-multi-version-test
new file mode 100755 (executable)
index 0000000..99fd775
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of 1 files two times, and restore
+#   them with the regex %m option. Files will be restored
+#   in $tmp with the mtime postfixed (fr.po -> fr.po.1534256893)
+#
+TestName="restore-multi-version-test"
+JobName=backup
+. scripts/functions
+
+${rscripts}/cleanup
+${rscripts}/copy-test-confs
+echo "$tmp/fr.po" >${tmp}/file-list
+
+cp $cwd/build/po/fr.po $tmp
+
+change_jobname CompressedTest $JobName
+start_test
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@output /dev/null
+messages
+@$out ${tmp}/log1.out
+label storage=File volume=TestVolume001
+run job=$JobName yes
+wait
+messages
+@exec "touch $tmp/fr.po"
+run job=$JobName yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@output /dev/null
+messages
+@$out ${tmp}/log2.out
+.bvfs_restore jobid=1 fileid=1 path=b21$$
+restore  file="?b21$$" regexwhere="!\$!.\$m!" yes
+.bvfs_cleanup path=b21$$
+.bvfs_restore jobid=2 fileid=2 path=b21$$
+restore  file="?b21$$" regexwhere="!\$!.\$m!" yes
+.bvfs_cleanup path=b21$$
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+
+check_for_zombie_jobs storage=File
+stop_bacula
+
+cnt=0
+for i in $tmp/fr.po.*
+do
+    cnt=`expr $cnt + 1`
+    diff $cwd/build/po/fr.po $i
+    if [ $? != 0 ]; then
+        print_debug "ERROR: found restore error for $i"
+        estat=1
+    fi
+done
+
+if [ "$cnt" != 2 ]; then
+    print_debug "ERROR: should found 2 files restored"
+    estat=1
+fi
+
+check_two_logs
+end_test