1#!/bin/sh 2 3# 4# previous versions (<= 17.2.4) had a problem with bvfs after running dbcheck. 5# Therefore this test checks 6# * check bvfs root directory 7# * run all dbcheck fixes 8# * check bvfs root directory again 9# 10 11. scripts/functions 12 13check_bvfs_root_path() 14{ 15 LOG="${1}" 16 17cat <<END_OF_DATA >${tmp}/bconcmds 18@$out ${LOG} w 19.bvfs_lsdir jobid=${BackupJobIds} path= 20END_OF_DATA 21 22 run_bconsole 23 24 check_log ${LOG} 25 # expect: 26 # 10 0 0 A A A A A A A A A A A A A A . 27 # 9 0 0 A A A A A A A A A A A A A A / 28 # 8 0 0 A A A A A A A A A A A A A A @bpipe@/ 29 if ! grep -q "\W/$" ${LOG}; then 30 set_error "root directory not found (using '.bvfs_lsdir path=')." 31 exit 1 32 fi 33 34 if ! grep -q "\W@bpipe@/$" ${LOG}; then 35 set_error "@bpipe@ plugin directory not found (using '.bvfs_lsdir path=')." 36 exit 1 37 fi 38} 39 40 41# Define the Name of the test as "TestName". 42# Should be the same as the filename, therefore we use the filename as default. 43TestName="`basename $0`" 44 45# set other test specific variables 46Client=bareos-fd 47JobName=backup-bareos-fd 48BackupJobIds="1,2" 49BvfsPathId="b201" 50 51# Directory to backup. 52# This directory will be created by setup_data(). 53BackupDirectory="${tmp}/data" 54BackupFileExtra=${BackupDirectory}/extrafile.txt 55 56# Remove old configuration, working and tmp files. Setup the database. 57cleanup 58 59# Config files will be copied to required location. 60# Base configuration files come from the 61# configs/BASE/ directory, see 62# configs/BASE/README.txt for an overview of the provides resources. 63# Store your additonal resources to 64# configs/$TestName. 65# It is also possible to overwrite resources from configs/BASE. 66# If you define a full config file (instead of config files for individual resources), 67# only these will be taken. 68copy_configs 69 70# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list". 71echo "${BackupDirectory}" >${tmp}/file-list 72 73# Use a tgz to setup data to be backuped. 74# Data will be placed at "${tmp}/data/". 75setup_data data/small.tgz 76 77# start the test 78start_test 79 80# activate bpipe-fd plugin 81enable_plugin bpipe-fd 82 83echo "Test Content 1" > ${BackupFileExtra} 84 85# ${tmp}/bconcmds lists the bconsole commands executed by "run_bareos" 86cat <<END_OF_DATA >${tmp}/bconcmds 87messages 88@$out ${tmp}/log-backup1.out w 89label storage=File1 pool=Default volume=TestVolume001 90run job=$JobName fileset=bpipe-fileset storage=File1 yes 91wait 92messages 93quit 94END_OF_DATA 95 96# Start the bareos daemons 97# and run the bconsole commands from ${tmp}/bconcmds 98# Further bconsole commands can be executed by "run_bconsole". 99run_bareos 100check_log ${tmp}/log-backup1.out 101 102 103# modify file and rerun backup 104echo "Test Content 2" >> ${BackupFileExtra} 105 106cat <<END_OF_DATA >${tmp}/bconcmds 107@$out ${tmp}/log-backup2.out w 108run job=$JobName fileset=bpipe-fileset storage=File1 yes 109wait 110messages 111quit 112END_OF_DATA 113 114run_bconsole 115check_log ${tmp}/log-backup2.out 116 117${bin}/bareos-dbcheck -vvv -b -f > ${tmp}/dbcheck-after-backups.log 118 119cat <<END_OF_DATA >${tmp}/bconcmds 120.bvfs_update 121@$out ${tmp}/log-bvfs-jobids.out w 122.bvfs_get_jobids jobid=2 123END_OF_DATA 124 125run_bconsole 126 127LOG=${tmp}/log-bvfs-jobids.out 128check_log ${LOG} 129# expect: 1,2 130if ! grep -q "^[0-9,]*2$" ${LOG}; then 131 set_error "failed to find required job ids." 132fi 133 134check_bvfs_root_path ${tmp}/log-bvfs-get-root-path-1.out 135 136${bin}/bareos-dbcheck -vvv -b -f > ${tmp}/dbcheck-after-bvfs-update.log 137 138check_bvfs_root_path ${tmp}/log-bvfs-get-root-path-2.out 139 140#cat <<END_OF_DATA >${tmp}/bconcmds 141#@$out ${tmp}/log-bvfs-get-root-path-offset.out w 142#.bvfs_lsdir jobid=${BackupJobIds} path= offset=1000 limit=1000 143# 144#@$out ${tmp}/log-bvfs-lsdir-root.out w 145#.bvfs_lsdir jobid=${BackupJobIds} path=/ 146# 147#@$out ${tmp}/log-bvfs-lsdir-BackupDirectory.out w 148#.bvfs_lsdir jobid=${BackupJobIds} path=${BackupDirectory}/ 149# 150#@$out ${tmp}/log-bvfs-lsfiles-BackupDirectory.out w 151#@#.bvfs_lsfiles jobid=${BackupJobIds} pathid=1 152#.bvfs_lsfiles jobid=${BackupJobIds} path=${BackupDirectory}/ 153# 154#@$out ${tmp}/log-bvfs-lsfiles-BackupDirectory-limit1.out w 155#.bvfs_lsfiles jobid=${BackupJobIds} path=${BackupDirectory}/ offset 0 limit 1 156# 157#@$out ${tmp}/log-bvfs-versions-extrafile.out w 158#.bvfs_versions jobid=0 client=${Client} path=${BackupDirectory}/ fname=extrafile.txt 159# 160#@$out ${tmp}/log-bvfs-lsfiles-bpipe-directory.out w 161#.bvfs_lsfiles jobid=${BackupJobIds} path=@bpipe@/ 162#END_OF_DATA 163# 164#run_bconsole 165 166cat <<END_OF_DATA >${tmp}/bconcmds 167@$out ${tmp}/log-bvfs-cache.out w 168.sql query="SELECT count(*) FROM Job WHERE HasCache!=0;" 169.sql query="SELECT count(*) FROM PathHierarchy;" 170.sql query="SELECT count(*) FROM PathVisibility;" 171 172@$out ${tmp}/log-bvfs-clear-cache.out w 173.bvfs_clear_cache yes 174 175@$out ${tmp}/log-bvfs-cleared-cache-hascache.out w 176.sql query="SELECT count(*) FROM Job WHERE HasCache!=0;" 177@$out ${tmp}/log-bvfs-cleared-cache-PathHierarchy.out w 178.sql query="SELECT count(*) FROM PathHierarchy;" 179@$out ${tmp}/log-bvfs-cleared-cache-PathVisibility.out w 180.sql query="SELECT count(*) FROM PathVisibility;" 181 182quit 183END_OF_DATA 184 185run_bconsole 186 187${bin}/bareos-dbcheck -vvv -b -f > ${tmp}/dbcheck-after-bvfs-clear-cache.log 188 189cat <<END_OF_DATA >${tmp}/bconcmds 190.bvfs_update 191END_OF_DATA 192 193run_bconsole 194 195check_bvfs_root_path ${tmp}/log-bvfs-get-root-path-3.out 196 197# verify that all are terminated 198check_for_zombie_jobs storage=File1 client=${Client} 199 200# stop bareos 201stop_bareos 202 203LOG=${tmp}/log-bvfs-cleared-cache-hascache.out 204check_log ${LOG} 205# expect: 206# .sql query="SELECT count(*) FROM Job WHERE HasCache!=0;" 207# +----------+ 208# | count(*) | 209# +----------+ 210# | 0 | 211# +----------+ 212# 213# Get the 5. line and remove all "|" and " " 214COUNT=`sed -e '5!d' -e 's/|//g' -e 's/ //g' $LOG` 215if [ "${COUNT}" -ne "0" ]; then 216 set_error "after .bvfs_clear_cache HasCache should be 0, not ${COUNT}." 217fi 218 219LOG=${tmp}/log-bvfs-cleared-cache-PathHierarchy.out 220check_log ${LOG} 221COUNT=`sed -e '5!d' -e 's/|//g' -e 's/ //g' $LOG` 222if [ "${COUNT}" -ne "0" ]; then 223 set_error "after .bvfs_clear_cache PathHierarchy table should be empty (but has ${COUNT} entries)." 224fi 225 226LOG=${tmp}/log-bvfs-cleared-cache-PathVisibility.out 227check_log ${LOG} 228COUNT=`sed -e '5!d' -e 's/|//g' -e 's/ //g' $LOG` 229if [ "${COUNT}" -ne "0" ]; then 230 set_error "after .bvfs_clear_cache PathVisibility table should be empty (but has ${COUNT} entries)." 231fi 232 233# end tests and check for error codes 234end_test 235