1#!/bin/sh
2#
3# Run a simple backup, then restore it.
4#
5TestName="backup-bareos-client-initiated-connection-test"
6JobName=backup
7
8. scripts/functions
9
10scripts/cleanup
11scripts/copy-confs
12
13# Directory to backup.
14# This directory will be created by setup_data().
15BackupDirectory="${tmp}/data"
16
17# Use a tgz to setup data to be backuped.
18# Data will be placed at "${tmp}/data/".
19setup_data data/small.tgz
20
21# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
22echo "${BackupDirectory}" >${tmp}/file-list
23
24#
25# Zap out any schedule in default conf file so that
26#  it doesn't start during our test
27#
28outf="$tmp/sed_tmp"
29echo "s%  Schedule =%# Schedule =%g" >${outf}
30cp ${conf}/bareos-dir.conf $tmp/1
31sed -f ${outf} $tmp/1 >${conf}/bareos-dir.conf
32
33dircfg=$conf/bareos-dir.conf
34$bperl -e "add_attribute('$dircfg', 'Connection From Director To Client', 'yes', 'Client')"
35$bperl -e "add_attribute('$dircfg', 'Connection From Client To Director', 'no', 'Client')"
36
37fdcfg=$conf/bareos-fd.conf
38$bperl -e "add_attribute('$fdcfg', 'Address', 'localhost', 'Director')"
39$bperl -e "add_attribute('$fdcfg', 'Connection From Client To Director', 'no', 'Director')"
40$bperl -e "add_attribute('$fdcfg', 'Connection From Director To Client', 'yes', 'Director')"
41
42change_jobname BackupClient1 $JobName
43start_test
44
45cat <<END_OF_DATA >$tmp/bconcmds
46@$out /dev/null
47messages
48@$out $tmp/log1.out
49run job=$JobName yes
50wait
51messages
52@#
53@# now do a restore
54@#
55@$out $tmp/log2.out
56restore where=$tmp/bareos-restores select all done
57yes
58wait
59messages
60quit
61END_OF_DATA
62
63run_bareos
64check_for_zombie_jobs storage=File
65stop_bareos
66
67#
68# Now do a second backup after making a few changes
69#
70echo "test test" > ${BackupDirectory}/xxx
71
72cat <<END_OF_DATA >$tmp/bconcmds
73@$out /dev/null
74messages
75@$out $tmp/log1.out
76run job=$JobName yes
77wait
78messages
79@#
80@# now do a restore
81@#
82@$out $tmp/log2.out
83restore where=$tmp/bareos-restores select all done
84yes
85wait
86messages
87quit
88END_OF_DATA
89
90run_bareos
91check_for_zombie_jobs storage=File
92stop_bareos
93
94check_two_logs
95check_restore_diff
96end_test
97
98