1#!/bin/sh
2
3. scripts/functions
4
5#
6# Run a simple backup with encryption and a real sparse file.
7#
8TestName="sparse-encrypt-test"
9JobName=SparseTest
10
11scripts/cleanup
12scripts/copy-crypto-confs
13
14# Directory to backup.
15# This directory will be created by setup_data().
16BackupDirectory="${tmp}/data"
17
18# Use a tgz to setup data to be backuped.
19# Data will be placed at "${tmp}/data/".
20setup_data data/small.tgz
21
22# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
23echo "${BackupDirectory}" >${tmp}/file-list
24
25SPARSEFILE="${BackupDirectory}/gigaslam.gif"
26
27start_test
28
29# create a sparse file
30scripts/create_sparse_file.sh ${SPARSEFILE} 100M
31if [ $? != 0 ]; then
32    set_error "create_sparse_file failed."
33    rm -f ${SPARSEFILE}
34    exit 1
35fi
36
37if [ ! -e "${SPARSEFILE}" ]; then
38    set_error "Failed to create sparse file."
39    exit 1
40fi
41
42cat >${cwd}/tmp/bconcmds <<END_OF_DATA
43@$out /dev/null
44messages
45@$out ${cwd}/tmp/log1.out
46label storage=File volume=TestVolume001
47setdebug level=10 fd
48run job=$JobName yes
49wait
50messages
51list volumes
52@#
53@# now do a restore
54@#
55@$out ${cwd}/tmp/log2.out
56@# setdebug level=0 fd
57restore where=${cwd}/tmp/bareos-restores storage=File
585
59mark *
60done
61yes
62wait
63messages
64quit
65END_OF_DATA
66
67run_bareos
68check_for_zombie_jobs storage=File
69stop_bareos
70
71check_two_logs
72check_restore_diff "${BackupDirectory}"
73
74size_orig=`get_file_size ${SPARSEFILE}`
75size=`get_file_size ${cwd}/tmp/bareos-restores/${SPARSEFILE}`
76if [ -z "$size" ]; then
77    set_error "Failed to determine size of restored sparse file."
78# TODO: encrypted sparse files are not handled as sparse files.
79#elif [ $size -gt 120 ]; then
80#    set_error "Restored sparse file ${SPARSEFILE} is too big (${size}K > 120K)"
81fi
82
83print_debug "size orig:     $size_orig"
84print_debug "size restored: $size"
85
86rm -f ${SPARSEFILE}
87
88end_test
89