1#!/bin/sh
2#
3# Run a simple backup  then migrate it
4#   to another device, then see how prune code handle that
5#
6# This script uses the virtual disk autochanger
7#
8TestName="prune-migration-test"
9JobName=MigrationJobSave
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
30change_jobname NightlySave $JobName
31dircfg=$conf/bareos-dir.conf
32$bperl -e "add_attribute('$dircfg', 'AutoPrune', 'No', 'Client')"
33$bperl -e "add_attribute('$dircfg', 'Job Retention', '1s', 'Client')"
34
35start_test
36
37#
38# Note, we first backup into Pool Default,
39#          then Migrate into Pool Full.
40#              Pool Default uses Storage=File
41#              Pool Full    uses Storage=DiskChanger
42
43# Write out bconsole commands
44cat <<END_OF_DATA >${cwd}/tmp/bconcmds
45@$out /dev/null
46messages
47@$out ${cwd}/tmp/log1.out
48setdebug level=000 storage=File
49label storage=File volume=FileVolume001 Pool=Default
50label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
51label storage=DiskChanger volume=ChangerVolume002 slot=2 Pool=Full drive=0
52@# run two jobs (both will be migrated)
53run job=$JobName yes
54@sleep 2
55run job=$JobName yes
56@sleep 2
57wait
58list jobs
59@# should migrate two jobs
60run job=migrate-job yes
61wait
62messages
63list jobs
64wait
65@sleep 2
66@#
67@# Now do another backup, but level Incremental
68@#
69run job=$JobName level=Incremental yes
70wait
71messages
72@sleep 2
73@################################################################
74@$out $cwd/tmp/log10.out
75setdebug level=1 director
76sql
77SELECT JobId, JobTDate, StartTime, EndTime FROM Job;
78
79list jobs
80prune jobs jobtype=backup yes
81@sleep 90
82list jobs
83sql
84SELECT JobId, JobTDate, StartTime, EndTime FROM Job;
85
86@################################################################
87@# now do a restore
88@#
89@$out ${cwd}/tmp/log2.out
90list volumes
91restore where=${cwd}/tmp/bareos-restores select storage=DiskChanger
92unmark *
93mark *
94done
95yes
96list volumes
97wait
98messages
99quit
100END_OF_DATA
101
102run_bareos
103check_for_zombie_jobs storage=File
104stop_bareos
105
106check_two_logs
107check_restore_diff
108
109# Now we will verify that the pruning code is working as expected.  Each time,
110# we run 'list jobs', 'prune', 'list jobs'. check_prune_list ensures that jobids
111# in argument are present in the first 'list jobs', the 'prune' command deletes
112# them (same number), and checks that the last 'list jobs' doesn't contain them
113# anymore. See scripts/functions.pm for details.
114
115# M M g g F F I0 -> F
116$bperl -e "check_prune_list('$tmp/log10.out',1,2,5,8)"
117estat=$(($estat + $?))
118
119end_test
120