1#!/bin/sh 2# 3# Run a backup on two Volumes 4# then copy it to another device. 5# 6# This script uses the virtual disk autochanger and migration scripts 7# 8TestName="copy-volume-test" 9JobName=MigVolBackup 10. scripts/functions 11 12 13scripts/cleanup 14scripts/copy-migration-confs 15scripts/prepare-disk-changer 16#cp ${cwd}/bin/bareos-sd.conf ${cwd}/tmp/1 17#sed "s%# Maximum File Size% Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bareos-sd.conf 18change_jobname NightlySave $JobName 19sed 's/migrate/copy/g' ${cwd}/bin/bareos-dir.conf > ${cwd}/tmp/1 20sed 's/Migrate/Copy/g' ${cwd}/tmp/1 > ${cwd}/bin/bareos-dir.conf 21 22# Directory to backup. 23# This directory will be created by setup_data(). 24BackupDirectory="${tmp}/data" 25 26# Use a tgz to setup data to be backuped. 27# Data will be placed at "${tmp}/data/". 28setup_data data/small.tgz 29 30# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list". 31echo "${BackupDirectory}" >${tmp}/file-list 32 33 34start_test 35 36# 37# Note, we first backup into Pool Default, 38# then Copy into Pool Full. 39# Pool Default uses Storage=File 40# Pool Full uses Storage=DiskChanger 41 42# Write out bconsole commands 43cat <<END_OF_DATA >${cwd}/tmp/bconcmds 44@$out /dev/null 45messages 46@$out ${cwd}/tmp/log1.out 47label storage=File volume=FileVolume001 Pool=Default 48label storage=File volume=FileVolume002 Pool=Scratch 49update Volume=FileVolume001 MaxVolBytes=3000000 pool=Default 50label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Scratch drive=0 51label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Scratch drive=0 52@# 53run job=$JobName yes 54wait 55run job=$JobName yes 56wait 57update volume=FileVolume001 VolStatus=Used 58update volume=FileVolume002 VolStatus=Used 59@#list volumes 60@#list jobs 61messages 62@$out ${cwd}/tmp/log11.out 63@############################################################ 64@# should copy one job, and the second is empty 65@############################################################ 66@# setdebug level=11 dir 67@echo "Run copy-volume Job" 68@#setdebug level=100 dir 69run job=copy-volume yes 70@sleep 5 71list jobs 72llist jobid=1 73llist jobid=2 74llist jobid=3 75llist jobid=4 76llist jobid=5 77status storage=DiskChanger 78wait 79list volumes 80list jobs 81llist jobid=1 82llist jobid=2 83llist jobid=3 84llist jobid=4 85llist jobid=5 86sql 87select * from JobMedia where JobId=1; 88 89messages 90@$out ${cwd}/tmp/log2.out 91@############################################################ 92@# now do a restore 93@# Expect: 94@# Check that copy uses JobId 1,2 95@# Use File instead of DiskChanger 96@# Files are there 97@############################################################ 98restore where=${cwd}/tmp/bareos-restores select 99unmark * 100mark * 101done 102yes 103wait 104messages 105quit 106END_OF_DATA 107 108run_bareos 109check_for_zombie_jobs storage=File 110check_restore_diff 111 112# cleanup previous restore 113rm -rf ${cwd}/tmp/bareos-restores 114 115cat <<END_OF_DATA >${cwd}/tmp/bconcmds 116@############################################################ 117@# Purge File backup, and restore again 118@# Expect: 119@# Check that copy uses other JobId 120@# Use DiskChanger 121@# Files are there 122@############################################################ 123@$out ${cwd}/tmp/log3.out 124purge volume=FileVolume001 yes 125purge volume=FileVolume002 yes 126restore where=${cwd}/tmp/bareos-restores select storage=DiskChanger 127unmark * 128mark * 129done 130yes 131wait 132messages 133quit 134END_OF_DATA 135 136run_bconsole 137 138check_for_zombie_jobs storage=DiskChanger 139check_restore_diff 140 141# cleanup previous restore 142rm -rf ${cwd}/tmp/bareos-restores 143touch ${BackupDirectory}/test.po 144 145cat <<END_OF_DATA >${cwd}/tmp/bconcmds 146@############################################################ 147@# Run a new Incremental, restore melting Copy and Backup 148@# and copy the new job to Changer 149@# Expect: 150@# Files are there 151@# Copy OK 152@############################################################ 153@$out ${cwd}/tmp/log4.out 154run job=$JobName yes 155wait 156messages 157restore where=${cwd}/tmp/bareos-restores select all 158done 159yes 160wait 161messages 162update volume=FileVolume001 VolStatus=Used 163update volume=FileVolume002 VolStatus=Used 164run job=copy-volume yes 165wait 166messages 167quit 168END_OF_DATA 169 170run_bconsole 171 172check_for_zombie_jobs storage=DiskChanger 173check_restore_diff 174 175stop_bareos 176 177get_mig_info 1 ${cwd}/tmp/log11.out 178 179if [ -z "$RET" -o "$RET" = 0 ]; then 180 bstat=2 181 print_debug "The first job must have been copied" 182fi 183 184get_mig_info 2 ${cwd}/tmp/log11.out 185 186if [ -n "$RET" ]; then 187 bstat=2 188 print_debug "The second job has no files, it can't have been copied" 189fi 190 191JOBID=`awk -F= '/Job queued. JobId/ {if(!f){print $2; f=1;}}' ${cwd}/tmp/log4.out` 192get_mig_info $JOBID ${cwd}/tmp/log4.out 193 194if [ -z "$RET" -o "$RET" = 0 ]; then 195 bstat=2 196 print_debug "The new incremental job must have been copied" 197fi 198 199check_two_logs 200end_test 201