1#!/bin/sh
2
3. scripts/functions
4
5#
6# test backup with sha signatures (SHA512) of files
7#
8
9# Define the Name of the test as "TestName".
10# Should be the same as the filename, therefore we use the filename as default.
11TestName="`basename $0`"
12#TestName="1-example-test"
13
14# set other test specific variables
15Client=bareos-fd
16JobName=backup-bareos-fd
17Storage=File1
18VolumeName=TestVolume001
19
20# Directory to backup.
21# This example uses a subdirectory
22# that contains some file but isn't to large.
23BackupDirectory="${tmp}/data"
24
25# Remove old configuration, working and tmp files. Setup the database.
26cleanup
27
28setup_data data/small.tgz
29
30# Config files will be copied to required location.
31# Base configuration files come from the
32# configs/BASE/ directory, see
33# configs/BASE/README.txt for an overview of the provides resources.
34# Store your additonal resources to
35# configs/$TestName.
36# It is also possible to overwrite resources from configs/BASE.
37# If you define a full config file (instead of config files for individual resources),
38# only these will be taken.
39copy_configs
40
41# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
42echo "${BackupDirectory}" >${tmp}/file-list
43
44# start the test
45start_test
46
47# ${tmp}/bconcmds lists the bconsole commands executed by "run_bareos"
48cat <<END_OF_DATA >${tmp}/bconcmds
49messages
50@$out ${tmp}/log-config.out
51show client=${Client}
52@$out ${tmp}/log1.out w
53label storage=File1 pool=Default volume=TestVolume001
54run job=$JobName storage=File1 yes
55wait
56messages
57@#
58@# now do a restore
59@#
60@$out ${tmp}/log2.out w
61restore client=${Client} where=${tmp}/bareos-restores select storage=File1
62unmark *
63mark *
64done
65yes
66wait
67messages
68quit
69END_OF_DATA
70
71# Start the bareos daemons
72# and run the bconsole commands from ${tmp}/bconcmds
73# Further bconsole commands can be executed by "run_bconsole".
74run_bareos
75
76# verify that all are terminated
77if ! check_for_zombie_jobs storage=File1 client=${Client}; then
78    set_error "zombie jobs"
79fi
80
81# stop bareos
82stop_bareos
83
84# check log files for common error messages
85check_log ${tmp}/log1.out
86check_log ${tmp}/log2.out
87
88# check tmp/log1.out and tmp/log2.out for errors
89check_two_logs
90
91# check for differences between original files and restored files
92check_restore_diff ${BackupDirectory}
93
94# do some manual testing
95if [ ! -d ${BackupDirectory} ]; then
96    set_error "Directory ${BackupDirectory} does not exists any more."
97fi
98
99check_log ${tmp}/log-config.out
100if ! grep -qi "TlsRequire = yes" ${tmp}/log-config.out; then
101   set_error "client is not configured to use TLS."
102fi
103
104if ! bls_files_verbose "${Storage}" "${VolumeName}" | grep -q "SHA512"; then
105   set_error "no SHA512 signatures found."
106fi
107
108# end tests and check for error codes
109end_test
110
111