This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
/
sparse-file-test
executable file
·85 lines (69 loc) · 1.77 KB
/
sparse-file-test
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
#!/bin/sh
#
# Run a simple backup of the Bareos build directory using the Sparse option
# then restore it.
#
TestName="gigaslam-sparse-test"
JobName=SparseTest
#JobName=SparseCompressedTest
. scripts/functions
scripts/cleanup
scripts/copy-test-confs
# Directory to backup.
# This example uses a subdirectory of the bareos source/build directory,
# that contains some file but isn't to large.
BackupDirectory="${cwd}/build/src/tests/"
# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
echo "${BackupDirectory}" >${tmp}/file-list
mkdir -p "${BackupDirectory}"
SPARSEFILE="${BackupDirectory}/gigaslam.gif"
# create a sparse file
scripts/create_sparse_file.sh ${SPARSEFILE} 100M
if [ $? != 0 ]; then
set_error "create_sparse_file failed."
rm -f ${SPARSEFILE}
exit 1
fi
if [ ! -e "${SPARSEFILE}" ]; then
set_error "Failed to create sparse file."
exit 1
fi
start_test
cat >${cwd}/tmp/bconcmds <<END_OF_DATA
@$out /dev/null
messages
@$out ${cwd}/tmp/log1.out
label storage=File volume=TestVolume001
run job=$JobName yes
wait
messages
list volumes
@#
@# now do a restore
@#
@$out ${cwd}/tmp/log2.out
restore where=${cwd}/tmp/bareos-restores select storage=File
unmark *
mark *
done
yes
wait
messages
quit
END_OF_DATA
run_bareos
check_for_zombie_jobs storage=File
stop_bareos
size_orig=`du ${SPARSEFILE} | cut -f 1`
size=`du ${cwd}/tmp/bareos-restores/${SPARSEFILE} | cut -f 1`
if [ -z "$size" ]; then
set_error "Failed to determine size of restored sparse file."
elif [ $size -gt 120 ]; then
set_error "Restored sparse file ${SPARSEFILE} is too big (${size}K > 120K)"
fi
print_debug "size orig: $size_orig"
print_debug "size restored: $size"
check_two_logs
check_restore_diff "${BackupDirectory}"
rm -f ${SPARSEFILE}
end_test