1#!/bin/sh
2#
3# Run a backup  on two Volumes
4#   then migrate it to another device.
5#
6# This script uses the virtual disk autochanger
7#
8TestName="migration-volume-test"
9JobName=MigVolBackup
10. scripts/functions
11
12
13scripts/cleanup
14scripts/copy-migration-confs
15scripts/prepare-disk-changer
16
17# Directory to backup.
18# This directory will be created by setup_data().
19BackupDirectory="${tmp}/data"
20
21# Use a tgz to setup data to be backuped.
22# Data will be placed at "${tmp}/data/".
23setup_data data/small.tgz
24
25# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
26echo "${BackupDirectory}" >${tmp}/file-list
27
28
29#cp ${cwd}/bin/bareos-sd.conf ${cwd}/tmp/1
30#sed "s%# Maximum File Size%  Maximum File Size%" ${cwd}/tmp/1 >${cwd}/bin/bareos-sd.conf
31
32change_jobname NightlySave $JobName
33start_test
34
35#
36# Note, we first backup into Pool Default,
37#          then Migrate into Pool Full.
38#              Pool Default uses Storage=File
39#              Pool Full    uses Storage=DiskChanger
40
41# Write out bconsole commands
42cat <<END_OF_DATA >${cwd}/tmp/bconcmds
43@$out /dev/null
44messages
45@$out ${cwd}/tmp/log1.out
46label storage=File volume=FileVolume001 Pool=Default
47label storage=File volume=FileVolume002 Pool=Default
48update Volume=FileVolume001 MaxVolBytes=3000000 pool=Default
49label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
50label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
51@#
52run job=$JobName yes
53wait
54run job=$JobName yes
55wait
56update volume=FileVolume001 VolStatus=Used
57update volume=FileVolume002 VolStatus=Used
58@#list volumes
59@#list jobs
60@# should migrate two jobs
61@# setdebug level=11 dir
62@echo "Run migrate-volume Job"
63@#setdebug level=100 dir
64run job=migrate-volume yes
65@sleep 5
66list jobs
67llist jobid=1
68llist jobid=2
69llist jobid=3
70llist jobid=4
71llist jobid=5
72status storage=DiskChanger
73wait
74list volumes
75list jobs
76llist jobid=1
77llist jobid=2
78llist jobid=3
79llist jobid=4
80llist jobid=5
81sql
82select * from JobMedia where JobId=1;
83
84@# Now run a second Migration job, which should do nothing
85run job=migrate-volume yes
86wait
87list jobs
88@# ensure we don't pickup old backup by purging volume
89@# purge volume=FileVolume001
90@# purge volume=FileVolume002
91@echo "Now do a restore"
92messages
93@#
94@# now do a restore
95@#
96@$out ${cwd}/tmp/log2.out
97restore where=${cwd}/tmp/bareos-restores select storage=DiskChanger
98unmark *
99mark *
100done
101yes
102wait
103messages
104quit
105END_OF_DATA
106
107run_bareos
108check_for_zombie_jobs storage=File
109stop_bareos
110
111check_two_logs
112check_restore_diff
113end_test
114