1#!/bin/sh
2#
3# Run a simple backup then create some
4#   new files, do an Incremental and restore those two files.
5#
6# This script uses the virtual disk autochanger
7#
8TestName="incremental-2disk"
9JobName=Inc2disk
10. scripts/functions
11
12scripts/cleanup
13scripts/copy-2disk-confs
14scripts/prepare-disk-changer
15
16change_jobname $JobName
17
18# Directory to backup.
19# This directory will be created by setup_data().
20BackupDirectory="${tmp}/data"
21
22# Use a tgz to setup data to be backuped.
23# Data will be placed at "${tmp}/data/".
24setup_data data/flat-c.tgz
25echo "${BackupDirectory}/ficheriro1.txt" >${tmp}/restore-list
26echo "${BackupDirectory}/ficheriro2.txt" >>${tmp}/restore-list
27
28# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
29echo "${BackupDirectory}" >${tmp}/file-list
30
31
32start_test
33
34# Write out bconsole commands
35cat <<END_OF_DATA >${cwd}/tmp/bconcmds
36@$out /dev/null
37messages
38@$out ${cwd}/tmp/log1.out
39label storage=tape volume=TestVolume001 slot=1 Pool=Default drive=0
40label storage=tape volume=TestVolume002 slot=2 Pool=Default drive=0
41run job=$JobName yes
42wait
43messages
44quit
45END_OF_DATA
46
47run_bareos
48
49echo "ficheriro1.txt" >${BackupDirectory}/ficheriro1.txt
50echo "ficheriro2.txt" >${BackupDirectory}/ficheriro2.txt
51
52
53cat <<END_OF_DATA >${cwd}/tmp/bconcmds
54@$out /dev/null
55messages
56@$out ${cwd}/tmp/log1.out
57@# Force Incremental on the second Volume
58update volume=TestVolume001 VolStatus=Used
59run level=Incremental job=$JobName yes
60wait
61messages
62@#
63@# now do a restore
64@#
65@$out ${cwd}/tmp/log2.out
66restore where=${cwd}/tmp/bareos-restores
677
68<${cwd}/tmp/restore-list
69
70yes
71wait
72messages
73quit
74END_OF_DATA
75
76run_bconsole
77
78check_for_zombie_jobs storage=File
79stop_bareos
80
81check_two_logs
82check_restore_files_diff `cat ${tmp}/restore-list`
83
84
85#
86# This script seems to more or less randomly fail, so we
87#  add extra code here to produce a "dump" in the event of
88#  an error.
89#
90if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
91   cat ${cwd}/tmp/log1.out
92   echo "  "
93   cat ${cwd}/tmp/log2.out
94   echo "  "
95   diff -r ${BackupDirectory} ${cwd}/tmp/bareos-restores/${BackupDirectory}
96fi
97
98end_test
99