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 and two drives 7# 8# TODO: add check to verify that 2 drives are used. 9# 10TestName="2drive-incremental-2disk" 11#JobName="2drive2disk" 12 13# Directory to backup. 14# This directory will be created by setup_data(). 15BackupDirectory="${tmp}/data" 16 17. scripts/functions 18 19scripts/cleanup 20scripts/copy-2disk-drive-confs 21scripts/prepare-disk-changer 22 23#CLIENT=localhost-fd 24 25#change_jobname localhost-fd $JobName 26start_test 27 28# Directory to backup. 29# This directory will be created by setup_data(). 30BackupDirectory="${tmp}/data" 31 32# Use a tgz to setup data to be backuped. 33# Data will be placed at "${tmp}/data/". 34setup_data data/flat-c.tgz 35 36# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list". 37echo "${BackupDirectory}" >${tmp}/file-list 38 39# Turn off Prefer Mounted Volumes so we use 2 drives 40outf="${cwd}/tmp/sed_tmp" 41echo "s%# Prefer Mounted Volumes% Prefer Mounted Volumes%g" >${outf} 42cp ${confdir}/bareos-dir.conf ${cwd}/tmp/1 43# Comment the next line out to write everything to one drive 44# otherwise, it writes the two jobs to different drives 45sed -f ${outf} ${cwd}/tmp/1 >${confdir}/bareos-dir.conf 46 47# Write out bconsole commands 48cat <<END_OF_DATA >${cwd}/tmp/bconcmds 49@$out /dev/null 50messages 51@$out ${cwd}/tmp/log1.out 52setdebug level=3 dir 53setdebug level=3 storage=tape 54setdebug level=3 client=2drive2disk 55label storage=tape volume=TestVolume001 slot=1 Pool=Default drive=0 56label storage=tape volume=TestVolume002 slot=2 Pool=Default drive=1 57status storage=tape 58setdebug level=200 storage=tape 59run job=NightlySave yes 60run job=NightlySave yes 61run job=NightlySave yes 62run job=NightlySave yes 63run job=NightlySave yes 64wait jobid=2 65status storage=tape 66list volumes 67list jobs 68messages 69wait 70list volumes 71list jobs 72status storage=tape 73messages 74quit 75END_OF_DATA 76 77run_bareos 78echo "ficheriro1.txt" >${BackupDirectory}/ficheriro1.txt 79echo "ficheriro2.txt" >${BackupDirectory}/ficheriro2.txt 80 81echo "${BackupDirectory}/ficheriro1.txt" >${tmp}/restore-list 82echo "${BackupDirectory}/ficheriro2.txt" >>${tmp}/restore-list 83 84cat <<END_OF_DATA >${cwd}/tmp/bconcmds 85@$out /dev/null 86messages 87@$out ${cwd}/tmp/log1.out 88@# Force Incremental on the second Volume 89update volume=TestVolume001 VolStatus=Used 90status storage=tape 91list volumes 92@#setdebug level=120 storage=tape 93run level=Incremental job=NightlySave yes 94wait 95list volumes 96status storage=tape 97messages 98@# 99@# now do a restore 100@# 101@$out ${cwd}/tmp/log2.out 102restore where=${tmp}/bareos-restores 1037 104<${tmp}/restore-list 105 106yes 107wait 108messages 109quit 110END_OF_DATA 111 112run_bconsole 113 114check_for_zombie_jobs storage=tape 115 116stop_bareos 117 118check_two_logs 119# The restore should read from TestVolume002, which was on drive 1 120if ! grep TestVolume002 ${tmp}/log2.out >/dev/null 2>&1; then 121 rstat=1 122fi 123 124check_restore_files_diff `cat ${tmp}/restore-list` 125 126end_test 127 128