1#!/bin/sh
2
3. scripts/functions
4
5#
6# Check to use multiple fileset option blocks.
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
13# set other test specific variables
14Client=bareos-fd
15JobName=backup-bareos-fd
16Storage=File1
17VolumeName=TestVolume001
18
19# Directory to backup.
20# This example uses a subdirectory of the bareos source/build directory,
21# that contains some file but isn't to large.
22BackupDirectory="${tmp}/data"
23
24# Remove old configuration, working and tmp files. Setup the database.
25cleanup
26
27# Config files will be copied to required location.
28# Base configuration files come from the
29# configs/BASE/ directory, see
30# configs/BASE/README.txt for an overview of the provides resources.
31# Store your additonal resources to
32# configs/$TestName.
33# It is also possible to overwrite resources from configs/BASE.
34# If you define a full config file (instead of config files for individual resources),
35# only these will be taken.
36copy_configs
37
38for i in 1 2 3 4 5 6; do
39    mkdir -p ${tmp}/data/data$i
40    echo "test" > ${tmp}/data/data${i}/test.dat
41done
42
43# start the test
44start_test
45
46# ${tmp}/bconcmds lists the bconsole commands executed by "run_bareos"
47cat <<END_OF_DATA >${tmp}/bconcmds
48messages
49show fileset=FS_TESTJOB
50@$out ${tmp}/log1.out w
51label storage=${Storage} volume=${VolumeName} pool=Default
52run job=$JobName storage=${Storage} yes
53wait
54messages
55@#
56@# now do a restore
57@#
58@$out ${tmp}/log2.out w
59restore client=${Client} where=${tmp}/bareos-restores select storage=${Storage}
60unmark *
61mark *
62done
63yes
64wait
65messages
66quit
67END_OF_DATA
68
69# Start the bareos daemons
70# and run the bconsole commands from ${tmp}/bconcmds
71# Further bconsole commands can be executed by "run_bconsole".
72run_bareos
73
74# verify that all are terminated
75check_for_zombie_jobs storage=File1 client=${Client}
76
77# stop bareos
78stop_bareos
79
80# check tmp/log1.out and tmp/log2.out for errors
81check_two_logs
82
83# check for differences between original files and restored files
84# gives an error, because top-level data directory is not backuped
85# (and has therefore other permissions)
86check_restore_diff ${BackupDirectory}/data1
87check_restore_diff ${BackupDirectory}/data2
88check_restore_diff ${BackupDirectory}/data3
89check_restore_diff ${BackupDirectory}/data4
90#check_restore_diff ${BackupDirectory}/data5
91if [ -e ${tmp}/bareos-restores/${BackupDirectory}/data5 ]; then
92    set_error "Directory data5 has been restored, however it should be excluded from the backup."
93fi
94#check_restore_diff ${BackupDirectory}/data6
95if [ -e ${tmp}/bareos-restores/${BackupDirectory}/data6 ]; then
96    set_error "Directory data6 has been restored, however it should be excluded from the backup."
97fi
98
99# do some manual testing
100if ! [ -d ${BackupDirectory} ]; then
101    set_error "Directory ${BackupDirectory} does not exists any more."
102fi
103
104check_compression "${Storage}" "${VolumeName}" "1" "${tmp}/data/data2/test.dat" "gzip"
105check_compression "${Storage}" "${VolumeName}" "1" "${tmp}/data/data3/test.dat" "gzip" "9"
106# Warning: LZ4 compression support requested in fileset but not available on this platform. Disabling ...
107#check_compression "${Storage}" "${VolumeName}" "1" "${tmp}/data/data3/test.dat" "LZ4"
108
109# end tests and check for error codes
110end_test
111
112