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