--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Use incorrect name/password to connect each daemon
+# and check that we are properly kicked out
+#
+TestName="bad-password-test"
+JobName=backup
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-confs
+
+#
+# Zap out any schedule in default conf file so that
+# it doesn't start during our test
+#
+outf="$tmp/sed_tmp"
+echo "s% Schedule =%# Schedule =%g" >${outf}
+cp $scripts/bacula-dir.conf $tmp/1
+sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
+
+change_jobname BackupClient1 $JobName
+start_test
+
+cat <<END_OF_DATA >$tmp/bconcmds
+setdebug level=100 trace=1 client
+setdebug level=100 trace=1 storage
+quit
+END_OF_DATA
+
+run_bacula
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@output /dev/null
+messages
+@$out $tmp/log1.out
+reload
+status dir
+@$out $tmp/log2.out
+status client
+@$out $tmp/log3.out
+status storage
+quit
+END_OF_DATA
+
+run_bconsole
+
+cp $conf/*.conf $tmp/
+cp $tmp/bconcmds $tmp/bconcmds.tpl
+
+################################################################
+# Test FD with incorrect password
+cp $tmp/*.conf $conf/
+sed s:/log:/log-client: $tmp/bconcmds.tpl > $tmp/bconcmds
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Password', 'xxx', 'Client')"
+run_bconsole
+
+################################################################
+# Test SD with incorrect password
+cp $tmp/*.conf $conf/
+sed s:/log:/log-sd: $tmp/bconcmds.tpl > $tmp/bconcmds
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Password', 'xxx', 'Storage')"
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Password', 'xxx', 'Autochanger')"
+run_bconsole
+
+################################################################
+# Test DIR with incorrect password
+
+cp $tmp/*.conf $conf/
+sed s:/log:/log-cons: $tmp/bconcmds.tpl > $tmp/bconcmds
+
+$bperl -e "add_attribute('$conf/bconsole.conf', 'Password', 'xxx', 'Director')"
+run_bconsole
+
+################################################################
+# Test back with good passwords
+cp $tmp/*.conf $conf/
+sed s:/log:/log-back: $tmp/bconcmds.tpl > $tmp/bconcmds
+
+run_bconsole
+
+################################################################
+# Check logs, all daemons should answer the call
+nb=`grep "Daemon started" $tmp/log-back* | wc -l`
+if [ $nb != 3 ]; then
+ print_debug "ERROR: Should find 3 daemon status in $tmp/log-back*"
+ estat=1
+fi
+
+# Threads are taking some time to cleanup the memory
+sleep 7
+
+export CHECK_JOBMEDIA=0
+export CHECK_ENCRYPTION=0
+
+stop_bacula
+end_test
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Run a basejob backup of the Bacula build directory
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Run a couple of tests with bconsole
#
estat=5
fi
-perl -Mscripts::functions \
+$bperl \
-e "extract_resource('$conf/bconsole.conf', 'Director', '$HOST-dir')" \
> $tmp/1
sed "s/$HOST-dir/bconsole-test-dir/" $tmp/1 >> $conf/bconsole.conf
+$bperl \
+ -e "add_attribute('$conf/bconsole.conf', 'HistoryFile', '$tmp/histfile', 'Director', 'bconsole-test-dir')"
+
+$bperl \
+ -e "add_attribute('$conf/bconsole.conf', 'HistoryFileSize', '200', 'Director', 'bconsole-test-dir')" \
+
$bin/bconsole -t -c $conf/bconsole.conf > $tmp/1 < /dev/null
if [ $? -ne 0 ]; then
print_debug "configuration tweak failed"
estat=13
fi
+if [ ! -f $tmp/histfile ]; then
+ print_debug "bconsole history file not found"
+ estat=14
+fi
+
# Do not try to check jobmedia with this test
export CHECK_JOBMEDIA=0
-
+export CHECK_OPENFILE=0
stop_bacula
end_test
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Run a simple backup of the Bacula build directory but
# split the archive into two volumes, then build a BSR with
--- /dev/null
+#!/usr/bin/perl -w
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Small test to setup a backup with $nb_files*2 to backup,
+# then, we can run multiple full jobs over the directory
+# and create a "large" catalog.
+#
+use strict;
+
+# use bacula functions
+use scripts::functions;
+
+my $nb_files = 250000;
+my $SD="storage=File";
+
+# initialize the configuration
+if ($FORCE_DEDUP eq 'yes') {
+ system("scripts/copy-test-confs");
+} else {
+ system("scripts/copy-fifo-confs");
+ $SD = "";
+}
+
+start_test();
+
+# cleanup the previous conf
+cleanup();
+
+# Create 500,000 files in files directory
+create_many_hardlinks("$cwd/files", $nb_files);
+
+# initialize the fileset
+add_to_backup_list("$cwd/files/");
+
+# Do not use spooling
+add_attribute("$conf/bacula-dir.conf", "SpoolData", "no", "Job");
+
+# We will run the jobs as fast as possible
+set_global_maximum_concurrent_jobs(10);
+
+start_bacula();
+
+create_bconcmds(
+ "$out $tmp/log1.out",
+ "label volume=TestVolume001 pool=Scratch $SD");
+
+run_bconsole();
+
+create_bconcmds(
+ "run job=NightlySave level=full yes",
+ "run job=NightlySave level=full yes",
+ "run job=NightlySave level=full yes",
+ "run job=NightlySave level=full yes",
+ "run job=NightlySave level=full yes",
+ "run job=NightlySave level=full yes",
+ "wait",
+ "messages");
+
+run_bconsole();
+
+stop_bacula();
+
+end_test();
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Test if Bacula can handle big fileset
# This test create 2M files on a directory and
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Test if Bacula can handle big fileset
#
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Run a simple backup of the Bacula build directory. Create three
# tapes, each in a different pool, then run two jobs both of which
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Create a big Volume > 5 GB and backup to it to test disk
# seeking on big volumes. We cheat and artifically grow
JobName=bigvol
. scripts/functions
-if test x$FORCE_CLOUD = xyes ; then
- echo "\n=== Test $TestName skipped not compatible with Cloud ==="
- exit 0
-fi
-
+unset FORCE_CLOUD
scripts/cleanup
scripts/copy-test-confs
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Run a simple backup of the Bacula build directory then bls
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
-#
# Attempt to backup and restore a file with the bpipe plugin
#
TestName="bpipe-test"
@$out ${cwd}/tmp/log1.out
label storage=File1 volume=TestVolume001
estimate job=$JobName level=Full
-setdebug level=100 client=$CLIENT
@#setdebug level=50 traclient=$CLIENT
run job=$JobName storage=File1 yes
wait
bstat=1
fi
+nb=`grep $file $tmp/list | wc -l`
+if [ $nb -ne 1 ]; then
+ print_debug "ERROR: Should find the RestoreObject for $file in $tmp/list"
+ bstat=1
+fi
+
+nb=`grep Makefile $tmp/list | wc -l`
+if [ $nb -ne 1 ]; then
+ print_debug "ERROR: Should find the RestoreObject for Makefile in $tmp/list"
+ bstat=1
+fi
+
+nb=`grep restore_command $tmp/conf | wc -l`
+if [ $nb -ne 2 ]; then
+ print_debug "ERROR: Should find the RestoreObject for Makefile and $file in $tmp/conf"
+ bstat=1
+fi
cat <<EOF >$tmp/obj
restore_command="cat >$tmp/Makefile.bak"
@$out ${cwd}/tmp/log3.out
setdebug level=50 client=$CLIENT trace=1
@putfile obj1 $tmp/obj
-restore where=${cwd}/tmp select all storage=File1 done
+restore pluginrestoreconf="2:obj1" where=${cwd}/tmp select all storage=File1 done
yes
wait
setdebug level=0 client=$CLIENT trace=0
#
# Remove plugin so we can try the restore without the plugin
#
-mv -f ${cwd}/bin/plugins/bpipe-fd.so ${cwd}/bin/plugins/bpipe-fd.sox
+mkdir -p $tmp/empty
+$bperl -e 'add_attribute("$conf/bacula-fd.conf", "Plugin Directory", "$tmp/empty", "FileDaemon")'
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out ${cwd}/tmp/log2.out
@#
@# now do a restore without the plugin
@#
-@$out ${cwd}/tmp/log2.out
@#setdebug level=50 client=$CLIENT
+status client
restore where=${cwd}/tmp select all storage=File1 done
yes
wait
#
# Restore plugin
#
-mv -f ${cwd}/bin/plugins/bpipe-fd.sox ${cwd}/bin/plugins/bpipe-fd.so
+#$bperl -e 'add_attribute("$conf/bacula-fd.conf", "Plugin Directory", "$plugin", "FileDaemon")'
+
+grep "bpipe-fd" $tmp/log2.out > /dev/null
+if [ $? = 0 ]; then
+ print_debug "ERROR: Should not find plugin in client status output ($tmp/log2.out)"
+ estat=1
+fi
check_two_logs
#
# ****FIXME**** test that all three files are restored correctly
#
+diff ${cwd}/Makefile ${cwd}/tmp/Makefile.bak
+dstat=$?
+
+diff ${cwd}/${file} ${cwd}/tmp/${file}
+dstat=$(($dstat + $?))
+
diff ${cwd}/tmp/@bpipe@/${file} ${cwd}/${file}
dstat=$(($dstat + $?))
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2018 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# This is an open_bpipe() unit test
+#
+TestName="bpipe_test"
+. scripts/functions
+make -C $src/src/tools install-unittests
+
+$bin/$TestName
+exit $?
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Attempt to backup and restore a file with the bpipe plugin and
+# play with stdout/stderr
+#
+TestName="bpipe2-test"
+JobName=pluginTest
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-plugin-confs
+
+file=bpipe.sh
+rm -rf ${cwd}/tmp/*
+echo "${cwd}/README" >${cwd}/tmp/file-list
+
+start_test
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+label storage=File1 volume=TestVolume001
+run job=$JobName fileset=bpipe storage=File1 yes
+wait
+status client=$CLIENT
+messages
+@$out ${cwd}/tmp/log3.out
+restore comment="Should finish in error" select all done yes
+wait
+messages
+quit
+END_OF_DATA
+
+# make check_two_logs happy
+touch $tmp/log2.out
+
+run_bacula
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out $tmp/files
+list files jobid=1
+END_OF_DATA
+
+run_bconsole
+
+if ! test -f $tmp/bpipe.sh
+then
+ print_debug "ERROR: Unable to find $tmp/bpipe.sh"
+ estat=1
+fi
+
+$rscripts/bpipe.sh > $tmp/1 2> /dev/null
+
+if ! diff $tmp/bpipe.sh $tmp/1
+then
+ print_debug "ERROR: Found a difference in $tmp/bpipe.sh and $tmp/1"
+ estat=1
+fi
+
+str="This is a message for Bacula"
+grep "$str" $tmp/log1.out > /dev/null
+if [ $? -ne 0 ]
+then
+ print_debug "ERROR: Should find string in job log $tmp/log1.out"
+ estat=1
+fi
+
+str="This is an error message"
+grep "$str" $tmp/log3.out > /dev/null
+if [ $? -ne 0 ]
+then
+ print_debug "ERROR: Should find '$str' in $tmp/log3.out"
+ estat=1
+fi
+
+str="An other line for Bacula"
+grep "$str" $tmp/log1.out > /dev/null
+if [ $? -ne 0 ]
+then
+ print_debug "ERROR: Should find '$str' in $tmp/log1.out"
+ estat=1
+fi
+
+str="This is an error message"
+grep "$str" $tmp/log3.out > /dev/null
+if [ $? -ne 0 ]
+then
+ print_debug "ERROR: Should find '$str' in $tmp/log3.out"
+ estat=1
+fi
+
+str="Last line for Bacula"
+grep "$str" $tmp/log3.out > /dev/null
+if [ $? -ne 0 ]
+then
+ print_debug "ERROR: Should find '$str' in $tmp/log3.out"
+ estat=1
+fi
+
+str="Error closing for file /@bpipe@/bpipe-error-restore.sh"
+grep "$str" $tmp/log3.out > /dev/null
+if [ $? -ne 0 ]
+then
+ print_debug "ERROR: Should find '$str' in $tmp/log3.out"
+ estat=1
+fi
+
+str="Error closing for file /@bpipe@/error"
+grep "$str" $tmp/log1.out > /dev/null
+if [ $? -ne 0 ]
+then
+ print_debug "ERROR: Should find '$str' in $tmp/log1.out"
+ estat=1
+fi
+
+stop_bacula
+end_test
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2018 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# This is an breaddir() unit test
+#
+TestName="breaddir_test"
+. scripts/functions
+make -C $src/src/tools install-unittests
+
+$bin/$TestName
+exit $?
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Show the broken media bug(s) again. Test by Graham Keeling.
#
start_test
-echo "Creating huge ${hugefilesize}M file..."
-dd if=/dev/urandom of="$hugefile" bs=1M count="$hugefilesize"
-echo "Done"
+#echo "Creating huge ${hugefilesize}M file..."
+dd if=/dev/urandom of="$hugefile" bs=1M count="$hugefilesize" >/dev/null 2>&1
+#echo "Done"
cat >tmp/bconcmds <<END_OF_DATA
@$out /dev/null
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-# Copyright (C) 2000-2015 Kern Sibbald
-# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Show the broken media bug. Test by Graham Keeling.
#
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Run a simple backup of the Bacula build directory using the compressed option
# then backup four times, each with incremental then
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory
+# Then stop the SD, corrupt the volume by adding few
+# bytes at the end, and run a set of new jobs.
+#
+# bscan the volume
+
+TestName="bscan-on-error-test"
+JobName=bscan
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-test-confs
+echo "${cwd}/build" >tmp/file-list
+
+change_jobname NightlySave $JobName
+start_test
+
+cat <<END_OF_DATA >tmp/bconcmds
+@$out /dev/null
+messages
+@$out tmp/log1.out
+label storage=File1
+TestVolume001
+run job=$JobName storage=File1
+yes
+wait
+sql
+select * from JobMedia;
+
+messages
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File1
+$bin/bacula-ctl-sd stop
+
+print_debug "Corrupting the volume..."
+echo "BB02" >> $tmp/TestVolume001
+
+$bin/bacula-ctl-sd start
+
+cat <<END_OF_DATA >tmp/bconcmds
+@$out /dev/null
+messages
+@$out tmp/log1.out
+run job=$JobName storage=File1 level=full yes
+wait
+sql
+select * from JobMedia;
+
+messages
+purge volume=TestVolume001
+quit
+END_OF_DATA
+
+run_bconsole
+
+echo "volume=TestVolume001" >$tmp/bscan.bsr
+bscan_libdbi
+
+# If the database has a password pass it to bscan
+if test "x${db_password}" = "x"; then
+ PASSWD=
+else
+ PASSWD="-P ${db_password}"
+fi
+
+if test "$debug" -eq 1 ; then
+ $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -S -p -b $tmp/bscan.bsr -s -c $conf/bacula-sd.conf $tmp
+else
+ $bin/bscan -w working $BSCANLIBDBI -u ${db_user} -n ${db_name} $PASSWD -S -r -p -v -b $tmp/bscan.bsr -s -c $conf/bacula-sd.conf $tmp >$tmp/log3.out 2>&1
+fi
+
+cat <<END_OF_DATA >tmp/bconcmds
+@$out /dev/null
+messages
+@$out tmp/log2.out
+restore where=$tmp/bacula-restores1 jobid=3 all done yes
+restore where=$tmp/bacula-restores2 jobid=4 all done yes
+wait
+messages
+quit
+END_OF_DATA
+
+$bin/bacula-ctl-sd stop
+$bin/bacula-ctl-sd start -p
+
+run_bconsole
+stop_bacula
+
+$rscripts/diff.pl -s $tmp/bacula-restores1/$cwd/build -d $cwd/build
+if [ $? != 0 ]; then
+ print_debug "ERROR: Unable to restore jobid 1 after bscan"
+ estat=1
+fi
+$rscripts/diff.pl -s $tmp/bacula-restores2/$cwd/build -d $cwd/build
+if [ $? != 0 ]; then
+ print_debug "ERROR: Unable to restore jobid 2 after bscan"
+ estat=1
+fi
+end_test
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Run a simple backup of the Bacula build directory using the compressed option
# then backup four times, each with incremental then
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Run a simple backup of the Bacula build directory but
# split the archive into two volumes then bscan it
#!/bin/sh
#
-# Copyright (C) 2000-2018 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Run a simple backup of the Bacula build directory but
# split the archive into two volumes, then restore
start_test
MaxVolBytes=3000000
+if test x$FORCE_DEDUP = xyes; then
+ MaxVolBytes=60000
+fi
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out /dev/null
messages
echo " "
exit 1
else
- echo " ===== End bsr-opt-test OK `date +%R:%S` ===== "
- echo " ===== End bsr-opt-test OK `date +%R:%S` ===== " >>test.out
+ echo " ===== bsr-opt-test Bacula source OK `date +%R:%S` ===== "
+ echo " ===== bsr-opt-test OK `date +%R:%S` ===== " >>test.out
scripts/cleanup
fi
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Run a backup of a small file, then do several other backups
# to expand the size of a volume. Then do a restore of the first
scripts/cleanup
scripts/copy-migration-confs
-scripts/prepare-disk-changer
cp ${cwd}/build/configure ${cwd}/tmp
cat ${cwd}/build/configure >> ${cwd}/tmp/configure
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory
+# then restore it.
+# Full Pool1 FileVolume001
+# Incr Pool1 FileVolume002 -> FileVolume001
+# Incr Pool1 - FileVolume001
+#
+# The 2nd incremental will spread data on a new volume
+# and on the previous volume.
+#
+# Volume SessTime/SessId FI New FI
+# rt-incr-disk1-10915 1563431298/23607 13 = 45
+# rt-incr-disk1-3547 1565527787/4 2 = 46
+# rt-incr-disk1-3547 1565527787/4 5 = 47
+# rt-incr-disk1-3547 1565527787/4 9 = 48
+# rt-incr-disk1-3547 1565527787/4 13 = 49
+# rt-incr-disk1-3547 1565527787/1151 2 = 50
+# rt-incr-disk1-10915 1565527787/1151 4 = 51
+# rt-incr-disk1-10915 1565527787/1151 10 = 52
+
+TestName="bsr-skip-issue-test"
+JobName=Vbackup
+. scripts/functions
+
+
+scripts/cleanup
+scripts/copy-migration-confs
+echo "${cwd}/build" >${cwd}/tmp/file-list
+
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'Accurate', 'yes', 'Job')"
+$bperl -e "add_attribute('$conf/bacula-dir.conf', 'SpoolData', 'no', 'Job')"
+$bperl -e "add_attribute('$conf/bacula-sd.conf', 'MaximumFileSize', '1MB', 'Device')"
+
+rm -f $cwd/build/inc1 $cwd/build/inc2 $cwd/build/diff1
+
+change_jobname NightlySave $JobName
+start_test
+
+# Write out bconsole commands
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+@#setdebug level=100 storage=File
+label storage=File volume=FileVolume001 Pool=Special
+label storage=File volume=FileVolume002 Pool=Special
+update volume=FileVolume002 maxvolbytes=1MB
+label storage=DiskChanger volume=ChangerVolume001 slot=1 Pool=Full drive=0
+@# run several jobs
+@exec "sh -c 'date > ${cwd}/build/date'"
+run job=$JobName level=Full pool=Special yes
+wait
+update volume=FileVolume001 volstatus=Used
+messages
+list jobs
+END_OF_DATA
+
+run_bacula
+
+$cwd/bin/bacula-ctl-sd restart
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out ${cwd}/tmp/log1.out
+@exec "touch $cwd/build/po/fr.po"
+@exec "sh -c 'cp $cwd/build/po/fr.po $cwd/build/inc1'"
+@exec "sh -c 'cp $cwd/build/po/fr.po $cwd/build/inc3'"
+run job=$JobName level=Incremental pool=Special yes
+wait mount
+update volume=FileVolume001 volstatus=Append
+mount storage=File drive=0 slot=0
+wait
+messages
+list jobs
+@exec "touch $cwd/build/po/de.po"
+@exec "sh -c 'cp $cwd/build/po/de.po $cwd/build/inc2'"
+run job=$JobName level=Incremental pool=Special yes
+wait
+messages
+@# should Consolidate Full, Incremental
+run job=$JobName level=VirtualFull yes
+wait
+messages
+list jobs
+@#
+@# now do a restore of the consolidated Full
+@#
+@$out $tmp/log2.out
+@#delete jobid=1,2,3 yes
+restore where=${cwd}/tmp/restore1 select all done yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+check_for_zombie_jobs storage=File
+stop_bacula
+
+#
+# We only used one log so copy it to the second log
+# so that any restore errors will be picked up
+#
+check_two_logs
+check_restore_diff
+
+end_test
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
-#
# Run a simple backup of the Bacula build directory
# then restore it. Used to generate BSR files.
#
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Test the fill command in btape
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
-#
# Test the fill command in btape
#
TestName="btape-fill-full-tape"
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
-#
# Test the test command in btape
#
TestName="btape-test"
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Test the test command in btape
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Test the test command in btape
#
start_test
if test "$debug" -eq 1 ; then
- $bin/btape -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA | tee ${cwd}/tmp/log1.out
+ $bin/btape -w $tmp -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA | tee ${cwd}/tmp/log1.out
test
quit
END_OF_DATA
else
- $bin/btape -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA >${cwd}/tmp/log1.out 2>&1
+ $bin/btape -w $tmp -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA >${cwd}/tmp/log1.out 2>&1
test
quit
END_OF_DATA
sed -e 's%64512%262144%' ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
if test "$debug" -eq 1 ; then
- $bin/btape -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA | tee ${cwd}/tmp/log2.out
+ $bin/btape -w $tmp -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA | tee ${cwd}/tmp/log2.out
test
quit
END_OF_DATA
else
- $bin/btape -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA >${cwd}/tmp/log2.out 2>&1
+ $bin/btape -w $tmp -c bin/bacula-sd.conf Drive-0 <<END_OF_DATA >${cwd}/tmp/log2.out 2>&1
test
quit
END_OF_DATA
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Test that reproduce bug 1227
#
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory then create some
+# new files, do an Incremental and restore those two files.
+#
+TestName="bug-7640"
+JobName=bug-7640
+. scripts/functions
+
+${rscripts}/cleanup
+${rscripts}/copy-test-confs
+echo $tmp/big >${tmp}/file-list
+echo $cwd/build/po >>${tmp}/file-list
+
+dd if=/dev/zero of=$tmp/big seek=1000000 count=1
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "SpoolData", "No", "Job")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "ClientRunBeforeJob", "\"sleep 30\"", "Job", "NightlySave")'
+$bperl -e 'add_attribute("$conf/bacula-sd.conf", "MaximumConcurrentJobs", "10", "Device")'
+sed -i 's/sparse=yes;//' $conf/bacula-dir.conf
+
+change_jobname NightlySave $JobName
+start_test
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@output /dev/null
+messages
+@$out ${tmp}/log1.out
+label storage=File volume=TestVolume000
+label storage=File volume=TestVolume001
+label storage=File volume=TestVolume002
+setdebug level=10 storage
+@# With VolUse=15s nothing restored for JobId 2
+@#update volume=TestVolume000 VolUse=15s
+@# With VolUse=20s both JobId 2 and 3 restore wrong size
+update volume=TestVolume000 VolUse=20s
+update volume=TestVolume001 maxvolbytes=100MB
+sql
+select VolumeName, MediaId FROM Media;
+
+run job=$JobName level=full yes
+@sleep 15
+setbandwidth limit="5000 kb/s" client=$CLIENT
+run job=$JobName level=full yes
+run job=$JobName level=full yes
+@sleep 20
+run job=$JobName level=full yes
+@sleep 10
+@#status client
+@#status dir
+@#status storage
+@sleep 10
+setbandwidth limit=0 client=$CLIENT
+wait
+messages
+sql
+select jobid, mediaid, firstindex,lastindex,volindex from JobMedia order by jobid,volindex;
+select * from JobMedia order by jobid,volindex;
+
+@$out $tmp/jobmedia2
+list jobmedia jobid=2
+@$out $tmp/jobmedia3
+list jobmedia jobid=3
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@#
+@# now do a restore that will fail (JobId 2)
+@#
+@$out ${tmp}/log2.out
+setdebug level=10 storage=File
+@# Select by JobId 2
+restore where=${tmp}/bacula-restores storage=File
+3
+2
+cd $tmp
+m big
+done
+yes
+wait
+@# Select by JobId 3
+restore where=${tmp}/bacula-restores2 storage=File
+3
+3
+cd $tmp
+m big
+done
+yes
+wait
+@#status client
+@#status storage=File
+messages
+quit
+END_OF_DATA
+
+run_bconsole
+check_for_zombie_jobs storage=File
+stop_bacula
+
+grep -q TestVolume000 $tmp/jobmedia2 && grep -q TestVolume001 $tmp/jobmedia2 && grep -q TestVolume002 $tmp/jobmedia2
+
+if [ $? -ne 0 ]; then
+ print_debug "ERROR: should find TestVolume{000, 001 and 002} volumes for JobId 2"
+ estat=1
+fi
+
+grep -q TestVolume001 $tmp/jobmedia3 && grep -q TestVolume002 $tmp/jobmedia3
+
+if [ $? -ne 0 ]; then
+ print_debug "ERROR: should find TestVolume{001 and 002} for JobId 3"
+ estat=1
+fi
+
+$bin/bls -c $conf/bacula-sd.conf -j -V 'TestVolume000|TestVolume001|TestVolume002' FileStorage > $tmp/bls.jobs
+$bin/bls -c $conf/bacula-sd.conf -V 'TestVolume000|TestVolume001|TestVolume002' FileStorage > $tmp/bls.files
+
+check_two_logs
+end_test
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Test bug 897
#
#!/bin/sh
#
-# Copyright (C) 2000-2015 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
-#
-
#
# Test RunScript
#
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory then restore a subdirectory
+# to see if some extra directories are restored also.
+#
+# On Windows, it creates a problem when using RegexWhere
+#
+# RegexWhere: !F:/priv/RZB1_Swiadectwa!!i,!^!F:/priv/RESTORE!
+# Bacula is trying to restore F:/priv/ and the regex engine is
+# creating a directory "F:/priv/RESTOREF:/priv/" which is not possible
+#
+TestName="bug-rwhere-7768"
+JobName=bug-rwhere-7768
+. scripts/functions
+
+${rscripts}/cleanup
+${rscripts}/copy-test-confs
+echo $cwd/build >${tmp}/file-list
+
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "SpoolData", "No", "Job")'
+sed -i 's/!restored/restored/i' $conf/bacula-fd.conf
+
+change_jobname NightlySave $JobName
+start_test
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@output /dev/null
+messages
+@$out ${tmp}/log1.out
+label storage=File volume=TestVolume000
+run job=$JobName level=full yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File
+
+cat <<END_OF_DATA >${tmp}/bconcmds
+@#
+@# now do a restore that will fail (JobId 2)
+@#
+@$out ${tmp}/log2.out
+setdebug level=10 storage=File
+restore strip_prefix="$cwd/build" add_prefix="$cwd/tmp" where=/ storage=File
+5
+cd $cwd/build
+m po
+done
+yes
+wait
+messages
+@$out $tmp/log3.out
+list joblog jobid=2
+quit
+END_OF_DATA
+
+run_bconsole
+check_for_zombie_jobs storage=File
+stop_bacula
+
+nb=`grep $tmp $tmp/log3.out | grep -v po | wc -l`
+if [ $nb -gt 0 ]; then
+ print_debug "ERROR: Should not find a line with $tmp in $tmp/log3.out, only po directory was selected"
+ estat=1
+fi
+
+check_two_logs
+end_test
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Run a simple backup of the Bacula build directory then create some
change_jobname CompressedTest $JobName
start_test
-$bperl -e 'add_attribute("$conf/bacula-dir.conf", "ClientRunBeforeJob", "sleep 2", "Job")'
+$bperl -e 'add_attribute("$conf/bacula-dir.conf", "ClientRunAfterJob", "sleep 2", "Job")'
cat <<END_OF_DATA >$tmp/bconcmds
@$out /dev/null
estat=`expr $estat + $?`
grep '^3$' $tmp/log6.out >/dev/null # with a filter on the date
estat=`expr $estat + $?`
-grep '^2$' $tmp/log7.out >/dev/null # with a filter on the date
+grep '^1$' $tmp/log7.out >/dev/null # with a filter on the date
estat=`expr $estat + $?`
stop_bacula
#!/bin/sh
#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
# Run a simple backup of the Bacula build directory then create some
# new files, do an Incremental and restore those two files.
# test the bvfs interface
#!/bin/sh
#
-# Copyright (C) 2000-2017 Kern Sibbald
+# Copyright (C) 2000-2020 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# Run a simple backup of the Bacula build directory then create some
mkdir -p ${tmpsrc}
cp -p ${src}/src/dird/*.c ${tmpsrc}
+mkdir $tmpsrc/directory
+echo test > $tmpsrc/directory/1
cd ${tmp}
echo "${tmpsrc}/ficheriro1.txt" >restore-list
echo "${tmpsrc}/ficheriro2.txt" >>restore-list
cp -f ficheriro2.txt 1
sed "s%a%b%g" 1 >ficheriro2.txt
rm -f 1
+rm -rf directory
cd ${cwd}
cat <<END_OF_DATA >${tmp}/bconcmds
@$out /dev/null
messages
@$out ${tmp}/log1.out
-run level=Differential job=$JobName yes
+run level=Differential accurate=yes job=$JobName yes
wait
messages
+@$out $tmp/log35.out
+.bvfs_update jobid=1,2,3,4
+.bvfs_lsdir jobid=1,2,3 path=$tmp/build/
+.bvfs_lsdir jobid=1,4 path=$tmp/build/
+@$out $tmp/log36.out
+sql
+SELECT * FROM PathVisibility JOIN Path USING (PathId) WHERE JobId=4;
+
quit
END_OF_DATA
touch ${tmpsrc}/ficheriro2.txt
ln ${tmpsrc}/ficheriro2.txt ${tmpsrc}/hardlink2
+# A linux system has 2000 symlinks
+for i in `seq 1 4000`
+do
+ cat /etc/hosts > ${tmpsrc}/file$i.txt
+ ln ${tmpsrc}/file$i.txt ${tmpsrc}/hl.$i
+done
+
+for i in `seq 1 50`
+do
+ ln ${tmpsrc}/file$i.txt ${tmpsrc}/hl2.$i
+done
+
cat <<END_OF_DATA >${tmp}/bconcmds
@$out /dev/null
messages
@$out ${tmp}/log3.out
.bvfs_update
.bvfs_lsdir path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8
-.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8
+.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8 limit=5000
@$out ${tmp}/log31.out
-.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7
+.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7 limit=5000
@$out ${tmp}/log32.out
.bvfs_lsfile path=$tmpsrc/ jobid=1,2,3,4,5,6,7,8 filename=ficheriro1.txt
quit
.bvfs_cleanup path=b21
END_OF_DATA
-jidx=`awk -F '\t' '/ficheriro2.txt|hardlinks2/ { lstat=$5 }
- END { print ".bvfs_decode_lstat lstat=\"" lstat "\""
-} ' $tmp/log3.out | $bin/bconsole -c $conf/bconsole.conf | awk -F= '/LinkFI/ { print $2 } '`
+# We get the last of ficheriro2.txt and hardlink2 to get the LinkFI
+jidx=`awk -F '\t' '/ficheriro2.txt|hardlink2/ { print "@echo fileid=" $3; print ".bvfs_decode_lstat lstat=\"" $5 "\"" } ' $tmp/log3.out | $bin/bconsole -c $conf/bconsole.conf | awk -F= '/LinkFI=[1-9][0-9]*/ { print $2 } '`
+
+fileid=`awk -F '\t' '/ficheriro2.txt|hardlink2/ { print "@echo fileid=" $3; print ".bvfs_decode_lstat lstat=\"" $5 "\"" } ' $tmp/log3.out | $bin/bconsole -c $conf/bconsole.conf | awk -F= '/fileid=/ { fileid=$2 } /LinkFI=[1-9][0-9]*/ { print fileid } '`
-awk '/ficheriro2.txt/ { if (!id) { id=$3 } } /hardlink2/ { if (!id) { id=$3 } }
- END {
- print ".bvfs_restore jobid=1,2,3,4,5,6,7,8 hardlink=8,'$jidx' fileid=" id " path=b21"
- } ' $tmp/log3.out >> $tmp/bconcmds
+# We take the last between ficheriro2.txt and hardlink2, and we restore both via the hardlink command
+echo ".bvfs_restore jobid=1,2,3,4,5,6,7,8 hardlink=8,$jidx fileid=$fileid path=b21" >> $tmp/bconcmds
cat <<END_OF_DATA >>${tmp}/bconcmds
@$out $tmp/log2.out
estat=1
fi
+nb=`grep directory/ $tmp/log35.out | wc -l`
+if [ $nb != 1 ]; then
+ print_debug "ERROR: Should find only one time directory/ in $tmp/log35.out"
+ estat=1
+fi
+
+nb=`grep directory/ $tmp/log36.out | wc -l`
+if [ $nb != 0 ]; then
+ print_debug "ERROR: Should not find directory/ in $tmp/log36.out"
+ estat=1
+fi
#
# Delete .c files because we will only restored the txt files
--- /dev/null
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory
+# and test the cancel all command
+#
+# We test "cancel all" => no/. nothing canceled, restore possible
+# We test "cancel all" => yes and "cancel all yes", two canceled jobs
+#
+TestName="cancel-all-test"
+JobName=backup
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-confs
+
+#
+# Zap out any schedule in default conf file so that
+# it doesn't start during our test
+#
+outf="$tmp/sed_tmp"
+echo "s% Schedule =%# Schedule =%g" >${outf}
+cp $scripts/bacula-dir.conf $tmp/1
+sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
+
+change_jobname BackupClient1 $JobName
+start_test
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@output /dev/null
+messages
+@$out $tmp/log1.out
+label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
+setbandwidth limit=2MB/s client
+run job=$JobName yes
+@sleep 2
+cancel all
+no
+cancel all
+.
+setbandwidth limit=100MB/s client
+wait
+messages
+@#
+@# now do a restore
+@#
+@$out $tmp/log2.out
+setdebug level=4 storage=File1
+restore where=$tmp/bacula-restores select all done
+yes
+wait
+messages
+@$out $tmp/log3.out
+setbandwidth limit=2MB/s client
+run job=$JobName level=full yes
+@sleep 2
+cancel all
+yes
+setbandwidth limit=100MB/s client
+wait
+messages
+@$out $tmp/log3.out
+setbandwidth limit=2MB/s client
+run job=$JobName level=full yes
+@sleep 2
+cancel all yes
+setbandwidth limit=100MB/s client
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File1
+stop_bacula
+
+nb=`grep "Backup Canceled" $tmp/log3.out | wc -l`
+if [ $nb != 2 ]; then
+ print_debug "ERROR: Should find two jobs canceled in $tmp/log3.out"
+ estat=1
+fi
+
+check_two_logs
+check_restore_diff
+end_test
#!/bin/sh
#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
# Run a simple backup of the Bacula build directory then copy it
# to another device.
#