1#!/bin/sh 2# 3# Run a simple backup 4# then restore it. 5# 6TestName="estimate-test" 7. scripts/functions 8JobName=BackupClient1FileList 9 10# Directory to backup. 11# This directory will be created by setup_data(). 12# If set, $BackupDirectory will be used 13# as base directory by check_restore_diff(). 14# Don't use a "/" at the end of the directory path, 15# as it might cause problems 16# (filenames given as parameter to restore must match 100%. "//" are not identical with "/"). 17BackupDirectory="${tmp}/data" 18 19# Remove old configuration, working and tmp files. Setup the database. 20cleanup 21 22# Use a tgz to setup data to be backuped. 23# Data will be placed at "${tmp}/data". 24setup_data data/small.tgz 25 26scripts/copy-confs 27 28# 29# Zap out any schedule in default conf file so that 30# it doesn't start during our test 31# 32outf="$tmp/sed_tmp" 33echo "s% Schedule =%# Schedule =%g" >${outf} 34cp ${conf}/bareos-dir.conf $tmp/1 35sed -f ${outf} $tmp/1 >${conf}/bareos-dir.conf 36 37start_test 38 39rm -rf ${cwd}/build/src/test ${cwd}/build/po/test 40mkdir -p ${BackupDirectory}/build/src/test 41mkdir -p ${BackupDirectory}/build/po/ 42touch ${BackupDirectory}/build/src/test/test1 ${BackupDirectory}/build/src/test/test2 43 44cat <<END_OF_DATA >$tmp/bconcmds 45@$out /dev/null 46messages 47@$out $tmp/log1.out 48label volume=TestVolume001 storage=File pool=Full 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 64 65check_two_logs 66check_restore_diff 67 68mv ${BackupDirectory}/build/src/test ${BackupDirectory}/build/po/test 69 70cat <<END_OF_DATA >$tmp/bconcmds 71@$out /dev/null 72messages 73@$out $tmp/log3.out 74estimate listing job=$JobName level=incremental 75messages 76quit 77END_OF_DATA 78 79run_bconsole 80 81cat <<END_OF_DATA >$tmp/bconcmds 82@$out /dev/null 83messages 84@$out $tmp/log4.out 85estimate listing job=$JobName level=incremental accurate=yes 86messages 87quit 88END_OF_DATA 89 90run_bconsole 91 92cp ${conf}/bareos-dir.conf $tmp/1 93sed 's/JobDefs {/JobDefs { Accurate=yes/' $tmp/1>${conf}/bareos-dir.conf 94 95cat <<END_OF_DATA >$tmp/bconcmds 96@$out /dev/null 97messages 98@$out $tmp/log5.out 99reload 100estimate listing job=$JobName level=incremental 101messages 102quit 103END_OF_DATA 104 105run_bconsole 106 107cat <<END_OF_DATA >$tmp/bconcmds 108@$out /dev/null 109messages 110@$out $tmp/log6.out 111estimate listing job=$JobName level=incremental accurate=no 112messages 113quit 114END_OF_DATA 115 116run_bconsole 117 118rm -rf ${BackupDirectory}/build/po/test 119 120grep test1 $tmp/log3.out > /dev/null 121if [ $? = 0 ]; then 122 print_debug "ERROR: Normal estimate shouldn't detect test1 file in $tmp/log3.out" 123 dstat=2 124fi 125 126grep test1 $tmp/log4.out > /dev/null 127if [ $? != 0 ]; then 128 print_debug "ERROR: Accurate=yes estimate should detect test1 file in $tmp/log4.out" 129 dstat=2 130fi 131 132grep test1 $tmp/log5.out > /dev/null 133if [ $? != 0 ]; then 134 print_debug "ERROR: Accurate estimate should detect test1 file in $tmp/log5.out" 135 dstat=2 136fi 137 138grep test1 $tmp/log6.out > /dev/null 139if [ $? = 0 ]; then 140 print_debug "ERROR: Accurate=no estimate shouldn't detect test1 file in $tmp/log6.out" 141 dstat=2 142fi 143 144check_for_zombie_jobs storage=File 145 146stop_bareos 147end_test 148