blob: 96177339d8908a3c9250bf058853e83aebbb2dc4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#!/bin/bash
set -o pipefail
set -u
#
# Stop the daemons while running backup.
# Check that metadata is still saved with checkpoints.
#
TestName="$(basename "$(pwd)")"
export TestName
#shellcheck source=../environment.in
. ./environment
#shellcheck source=../scripts/functions
. "${rscripts}"/functions
start_test
backup_log=$tmp/stop-backup-checkpoints.out
restore_log=$tmp/stop-restore-checkpoints.out
restore_directory=$tmp/stop-checkpoints-restore-directory
rm -f "$backup_log"
rm -f "$restore_log"
rm -rf "$restore_directory"
slowjob="slow-backup-bareos-fd"
cat <<END_OF_DATA >"$tmp/bconcmds"
@$out /dev/null
messages
@$out $backup_log
run job=$slowjob level=Full yes
quit
END_OF_DATA
run_bconsole
timeout=0
timed_checkpoint=""
volume_checkpoint=""
while [[ ${timeout} -lt 30 ]] && [[ -z $timed_checkpoint || -z $volume_checkpoint ]]
do
timed_checkpoint=$(grep -m 1 'Doing timed backup checkpoint. Next checkpoint in 3 seconds' "$messagesfile")
volume_checkpoint=$(grep -m 1 'Volume changed, doing checkpoint:' "$messagesfile")
sleep 1
((++timeout))
done
# Check that a timed checkpoint was triggered
if [[ -z $timed_checkpoint ]]; then
echo "Timed checkpoint was not triggered!"
estat=1;
fi
# Check that a checkpoint happened on a volume change
if [[ -z $volume_checkpoint ]]; then
echo "Checkpoint was not triggered on volume changes!"
estat=2;
fi
bin/bareos stop
bin/bareos start
slowjobid=$(grep 'Job queued. JobId=' "$backup_log" | sed -n -e 's/^.*JobId=//p')
cat <<END_OF_DATA >"$tmp/bconcmds"
@$out $backup_log
messages
@$out $restore_log
restore jobid=${slowjobid} where=$restore_directory all done yes
wait
messages
quit
END_OF_DATA
run_bconsole
NumberOfBackedUpFiles=$(grep 'FD Files Written: ' "$backup_log" | sed -n -e 's/^.*Written: //p')
# Check that part of the files were written despite the stop
if [ "$NumberOfBackedUpFiles" -le 0 ]; then
echo "Checkpoint files were not correctly saved! Number of backed up files: ${NumberOfBackedUpFiles}" >&2
estat=1
fi
# Check that the backup was halted
expect_not_grep "Termination:.*Backup OK" \
"$backup_log"\
"Backup was run successfully. The backup should fail."
# Check that the restore works fine
expect_grep "Termination: Restore OK" \
"$restore_log"\
"Restore job did not go well!"
# Certain systems do not support multiple types for find (-type f,l)
NumberOfFilesRestored=$(find "$restore_directory"/"$tmp" -type f | wc -l)
NumberOfLinksRestored=$(find "$restore_directory"/"$tmp" -type l | wc -l)
NumberOfDirectoriesRestored=$(find "$restore_directory"/"$tmp" -type d | wc -l)
RestoredItems=$((NumberOfFilesRestored + NumberOfLinksRestored + NumberOfDirectoriesRestored))
# Check that the restored files are actually there
if [ ${RestoredItems} -lt ${NumberOfBackedUpFiles} ]; then
echo "Actual restored items count not met. Items (files, links, directories) found = ${RestoredItems} , backed up files = ${NumberOfBackedUpFiles}" >&2
estat=1
fi
end_test
|