diff --git a/configs/BASE/bareos-dir.d/director/bareos-dir.conf.in b/configs/BASE/bareos-dir.d/director/bareos-dir.conf.in index bc29fd2..832ae28 100644 --- a/configs/BASE/bareos-dir.d/director/bareos-dir.conf.in +++ b/configs/BASE/bareos-dir.d/director/bareos-dir.conf.in @@ -16,11 +16,8 @@ Director { # define myself # remove comment in next line to load dynamic backends from specified directory # Backend Directory = @backenddir@ - # remove comment from "Plugin Directory" to load plugins from specified directory. - # if "Plugin Names" is defined, only the specified plugins will be loaded, - # otherwise all director plugins (*-dir.so) from the "Plugin Directory". - # - # Plugin Directory = @plugindir@ - # Plugin Names = "" + # If plugins should get used, call + # enable_plugin PLUGINNAME + Plugin Directory = @plugindirtmp@ } diff --git a/configs/BASE/bareos-dir.d/fileset/bpipe-fileset.conf.in b/configs/BASE/bareos-dir.d/fileset/bpipe-fileset.conf.in new file mode 100644 index 0000000..b6cf82c --- /dev/null +++ b/configs/BASE/bareos-dir.d/fileset/bpipe-fileset.conf.in @@ -0,0 +1,23 @@ +FileSet { + Name = bpipe-fileset + Include { + Options { + signature = MD5 + } + + # + # test different target files for bpipe + # + Plugin = "bpipe:file=/bpipe-file-in-root.txt:reader=find @rscripts@:writer=sh -c 'cat >@tmpdir@/root-bpipefile.txt'" + Plugin = "bpipe:file=@bpipe@/bpipe-dir-as-root-test.txt:reader=find @rscripts@:writer=sh -c 'cat >@tmpdir@/bpipe.txt'" + Plugin = "bpipe:file=@bpipe@/subdir/bpipe-dir-as-root-with-subdir-test.txt:reader=find @rscripts@:writer=sh -c 'cat >@tmpdir@/bpipe-subdir.txt'" + Plugin = "bpipe:file=/@bpipe@/bpipe-dir-in-root-test.txt:reader=find @rscripts@:writer=sh -c 'cat >@tmpdir@/root-bpipe.txt'" + Plugin = "bpipe:file=/@bpipe@/subdir/bpipe-dir-in-subdir-in-root-test.txt:reader=find @rscripts@:writer=sh -c 'cat >@tmpdir@/root-bpipe-subdir.txt'" + + # + # also backup normal file list + # + File = <@tmpdir@/file-list + } +} + diff --git a/configs/BASE/bareos-dir.d/job/RestoreFiles.conf b/configs/BASE/bareos-dir.d/job/RestoreFiles.conf.in similarity index 87% rename from configs/BASE/bareos-dir.d/job/RestoreFiles.conf rename to configs/BASE/bareos-dir.d/job/RestoreFiles.conf.in index c5834a6..5a6fa82 100644 --- a/configs/BASE/bareos-dir.d/job/RestoreFiles.conf +++ b/configs/BASE/bareos-dir.d/job/RestoreFiles.conf.in @@ -7,5 +7,5 @@ Job { Storage = File1 Pool = Default Messages = Standard - Where = /tmp/bareos-restores -} \ No newline at end of file + Where = @tmpdir@/bareos-restores +} diff --git a/configs/BASE/bareos-fd.d/client/myself.conf.in b/configs/BASE/bareos-fd.d/client/myself.conf.in index 2823ed3..e5746bd 100644 --- a/configs/BASE/bareos-fd.d/client/myself.conf.in +++ b/configs/BASE/bareos-fd.d/client/myself.conf.in @@ -3,16 +3,9 @@ Client { Fd Port = @fdport@ Maximum Concurrent Jobs = 20 - # remove comment from "Plugin Directory" to load plugins from specified directory. - # if "Plugin Names" is defined, only the specified plugins will be loaded, - # otherwise all storage plugins (*-fd.so) from the "Plugin Directory". - # - # Plugin Directory = @plugindir@ - # Plugin Names = "" - - # if compatible is set to yes, we are compatible with bacula - # if set to no, new bareos features are enabled which is the default - # compatible = yes + # If plugins should get used, call + # enable_plugin PLUGINNAME + Plugin Directory = @plugindirtmp@ TLS Require = yes TLS Certificate = "@confdir@/tls/client1.bareos.org-cert.pem" diff --git a/configs/BASE/bareos-sd.d/storage/bareos-sd.conf.in b/configs/BASE/bareos-sd.d/storage/bareos-sd.conf.in index 105d729..e394f7b 100644 --- a/configs/BASE/bareos-sd.d/storage/bareos-sd.conf.in +++ b/configs/BASE/bareos-sd.d/storage/bareos-sd.conf.in @@ -3,12 +3,9 @@ Storage { Sd Port = @sdport@ Maximum Concurrent Jobs = 20 - # remove comment from "Plugin Directory" to load plugins from specified directory. - # if "Plugin Names" is defined, only the specified plugins will be loaded, - # otherwise all storage plugins (*-sd.so) from the "Plugin Directory". - # - # Plugin Directory = @plugindir@ - # Plugin Names = "" + # If plugins should get used, call + # enable_plugin PLUGINNAME + Plugin Directory = @plugindirtmp@ TLS Require = yes TLS Certificate = "@confdir@/tls/bareos-sd1.bareos.org-cert.pem" diff --git a/scripts/cleanup b/scripts/cleanup index cfb62e2..e1106c0 100755 --- a/scripts/cleanup +++ b/scripts/cleanup @@ -19,6 +19,7 @@ rm -rf ${working}/*.bsr ${working}/log*.sd rm -rf ${working}/*.trace ${working}/*.traceback ${working}/*.bactrace rm -rf ${working}/*.state rm -rf ${working}/CLEANUPMARKER +rm -rf ${working}/plugins/* find . -name "gigaslam.gif" -exec rm -f {} \; # cleanup old config files # don't delete mtx-changer.conf (and other files?) diff --git a/scripts/create_sed b/scripts/create_sed index d44189d..ee500ce 100755 --- a/scripts/create_sed +++ b/scripts/create_sed @@ -42,7 +42,10 @@ echo "s%@archivedir@%${tmp}%g" >>${out} echo "s%@bindir@%${bin}%g" >>${out} echo "s%@sbindir@%${bin}%g" >>${out} echo "s%@scriptdir@%${scripts}%g" >>${out} +echo "s%@scripts@%${scripts}%g" >>${out} +echo "s%@rscripts@%${rscripts}%g" >>${out} echo "s%@plugindir@%${plugindir}%g" >>${out} +echo "s%@plugindirtmp@%${plugindirtmp}%g" >>${out} echo "s%@working_dir@%${working}%g" >>${out} echo "s%@piddir@%${working}%g" >>${out} echo "s%@job_email@%${EMAIL}%g" >>${out} @@ -60,8 +63,8 @@ echo "s%@hostname@%${hostname}%g" >>${out} echo "s%@hostname1@%${hostname1}%g" >>${out} echo "s%@hostname2@%${hostname2}%g" >>${out} echo "s%@hostname3@%${hostname3}%g" >>${out} -echo "s%@hostname1_files@%${hostname1_files}%g" >>${out} echo "s%@hostname_files@%${hostname_files}%g" >>${out} +echo "s%@hostname1_files@%${hostname1_files}%g" >>${out} echo "s%@hostname2_files@%${hostname2_files}%g" >>${out} echo "s%@hostname3_files@%${hostname3_files}%g" >>${out} echo "s%@hostname1_password@%${hostname1_password}%g" >>${out} diff --git a/scripts/functions b/scripts/functions index db553f6..661675a 100644 --- a/scripts/functions +++ b/scripts/functions @@ -39,6 +39,53 @@ copy_configs() done } +# +# activates a plugin by copying to $plugindirtmp. +# For this, daemons must have following setting: +# Plugin Directory = @plugindirtmp@ +# +enable_plugin() +{ + RC=0 + PLUGIN="$1" + + if [ -z "$PLUGIN" ]; then + set_error "enable_plugin: no plugin name given." + exit 1 + fi + + if ! cp $plugindir/${PLUGIN}.* $plugindirtmp/; then + set_error "enable_plugin: failed to enable ${PLUGIN} plugin." + RC=1 + exit 1 + fi + + print_debug "plugin ${PLUGIN} enabled" + + return $RC +} + +disable_plugin() +{ + RC=0 + PLUGIN="$1" + + if [ -z "$PLUGIN" ]; then + set_error "enable_plugin: no plugin name given." + exit 1 + fi + + if ! rm $plugindirtmp/${PLUGIN}.*; then + set_error "disable_plugin: failed to disable ${PLUGIN} plugin." + RC=1 + exit 1 + fi + + print_debug "plugin ${PLUGIN} disabled" + + return $RC +} + check_encoding() { ${bin}/bareos-dir -d50 -t 2>&1 | grep 'Wanted SQL_ASCII, got UTF8' >/dev/null @@ -363,7 +410,7 @@ run_bareos() if [ $DAEMON_STATUS -ne 0 ]; then exit 1 fi - + run_bconsole return $? } @@ -835,12 +882,16 @@ db_password=${db_password:-""} working=${working:-"$cwd/working"} dumps=${dumps:-"$cwd/dumps"} bin=${bin:-"$cwd/bin"} +tmp=${tmp:-"$cwd/tmp"} # Bareos scripts scripts=${scripts:-"$cwd/bin"} # Bareos Plugin Directory plugindir=${plugindir:-"$cwd/bin/plugins"} +# some tests (BASE) load only the plugins copied to plugindirtmp, +# to avoid that all plugins get loaded. +plugindirtmp=${plugindirtmp:-"$working/plugins"} # Bareos conf files conf=${conf:-"$cwd/bin"} @@ -854,7 +905,6 @@ rscripts=${rscripts:-"$cwd/scripts"} # Regress configs rconfigs=${rconfigs:-"$cwd/configs"} -tmp=${tmp:-"$cwd/tmp"} # Bareos source directory when copied here # also build directory @@ -868,13 +918,15 @@ export bin export conf export confdir export configs -export working export dumps -export scripts +export plugindir +export plugindirtmp export rscripts -export tmp +export scripts export src +export tmp export tmpsrc +export working export dirport=$BASEPORT export fdport=$(($BASEPORT + 1)) @@ -889,6 +941,7 @@ export bperl mkdir -p ${working} mkdir -p ${tmp} +mkdir -p ${plugindirtmp} touch ${tmp}/dir.out ${tmp}/fd.out ${tmp}/sd.out CLIENT=${HOST}-fd diff --git a/scripts/test-bareos-fd.conf.in b/scripts/test-bareos-fd.conf.in index 830b2a3..c98148b 100644 --- a/scripts/test-bareos-fd.conf.in +++ b/scripts/test-bareos-fd.conf.in @@ -21,7 +21,7 @@ FileDaemon { # this is me FDPort = @fdport@ # where we listen for the director WorkingDirectory = "@working_dir@" Pid Directory = "@piddir@" - Plugin Directory = "@plugindir@" + Plugin Directory = "@plugindirtmp@" Maximum Concurrent Jobs = 100 } diff --git a/tests/1-example-test b/tests/1-example-test index 0cd2cf5..4524b81 100755 --- a/tests/1-example-test +++ b/tests/1-example-test @@ -52,6 +52,9 @@ copy_configs # start the test start_test +# activate plugin, e.g. bpipe-fd +#activate_plugin bpipe-fd + # ${tmp}/bconcmds lists the bconsole commands executed by "run_bareos" cat <${tmp}/bconcmds messages diff --git a/tests/bvfs-test b/tests/bvfs-test index 4c18353..f763817 100755 --- a/tests/bvfs-test +++ b/tests/bvfs-test @@ -41,6 +41,9 @@ setup_data data/small.tgz # start the test start_test +# activate bpipe-fd plugin +enable_plugin bpipe-fd + echo "Test Content 1" > ${BackupFileExtra} # ${tmp}/bconcmds lists the bconsole commands executed by "run_bareos" @@ -48,7 +51,7 @@ cat <${tmp}/bconcmds messages @$out ${tmp}/log-backup1.out w label storage=File1 pool=Default volume=TestVolume001 -run job=$JobName storage=File1 yes +run job=$JobName fileset=bpipe-fileset storage=File1 yes wait messages quit @@ -66,7 +69,7 @@ echo "Test Content 2" >> ${BackupFileExtra} cat <${tmp}/bconcmds @$out ${tmp}/log-backup2.out w -run job=$JobName storage=File1 yes +run job=$JobName fileset=bpipe-fileset storage=File1 yes wait messages quit @@ -88,6 +91,9 @@ cat <${tmp}/bconcmds @$out ${tmp}/log-bvfs-get-root-path.out w .bvfs_lsdir jobid=${BackupJobIds} path= +@$out ${tmp}/log-bvfs-get-root-path-offset.out w +.bvfs_lsdir jobid=${BackupJobIds} path= offset=1000 limit=1000 + @$out ${tmp}/log-bvfs-lsdir-root.out w .bvfs_lsdir jobid=${BackupJobIds} path=/ @@ -98,8 +104,14 @@ cat <${tmp}/bconcmds @#.bvfs_lsfiles jobid=${BackupJobIds} pathid=1 .bvfs_lsfiles jobid=${BackupJobIds} path=${BackupDirectory}/ +@$out ${tmp}/log-bvfs-lsfiles-BackupDirectory-limit1.out w +.bvfs_lsfiles jobid=${BackupJobIds} path=${BackupDirectory}/ offset 0 limit 1 + @$out ${tmp}/log-bvfs-versions-extrafile.out w .bvfs_versions jobid=0 client=${Client} path=${BackupDirectory}/ fname=extrafile.txt + +@$out ${tmp}/log-bvfs-lsfiles-bpipe-directory.out w +.bvfs_lsfiles jobid=${BackupJobIds} path=@bpipe@/ END_OF_DATA run_bconsole @@ -171,12 +183,26 @@ fi LOG=${tmp}/log-bvfs-get-root-path.out check_log ${LOG} # expect: -# 10 0 0 0 A A A A A A A A A A A A A A . -# 9 0 0 0 A A A A A A A A A A A A A A / +# 10 0 0 A A A A A A A A A A A A A A . +# 9 0 0 A A A A A A A A A A A A A A / +# 8 0 0 A A A A A A A A A A A A A A @bpipe@/ if ! grep -q "\W/$" ${LOG}; then set_error "root directory not found (using '.bvfs_lsdir path=')." fi +if ! grep -q "\W@bpipe@/$" ${LOG}; then + set_error "@bpipe@ plugin directory not found (using '.bvfs_lsdir path=')." +fi + +LOG=${tmp}/log-bvfs-get-root-path-offset.out +check_log ${LOG} +# expect: empty file, as offset larger than number of dirs +dirs=`grep "^[0-9]\+\W" ${LOG} | wc -l` +if [ "$dirs" -gt 0 ]; then + set_error "result should be empty (using '.bvfs_lsdir path= offset=1000')." +fi + + LOG=${tmp}/log-bvfs-lsdir-root.out check_log ${LOG} # expect: @@ -203,6 +229,13 @@ if ! grep -q "\Wextrafile.txt" ${LOG}; then set_error "file not found using .bvfs_lsfiles." fi +LOG=${tmp}/log-bvfs-lsfiles-BackupDirectory-limit1.out +check_log ${LOG} +files=`grep "^[0-9]\+\W" ${LOG} | wc -l` +if [ "$files" != "1" ]; then + set_error "expected 1 file, found ${files}." +fi + LOG=${tmp}/log-bvfs-versions-extrafile.out check_log ${LOG} versions=`grep "^[0-9]\+\W" ${LOG} | wc -l` @@ -210,6 +243,12 @@ if [ "$versions" != "2" ]; then set_error "expected 2 versions of file ${BackupFileExtra}, found ${versions}." fi +LOG=${tmp}/log-bvfs-lsfiles-bpipe-directory.out +check_log ${LOG} +if ! grep -q "\Wbpipe-dir-as-root-test.txt" ${LOG}; then + set_error "bpipe plugin result file not found using .bvfs_lsfiles." +fi + LOG=${tmp}/log-bvfs-restore.out check_log ${LOG} # check for differences between original files and restored files diff --git a/tests/plugin-test b/tests/plugin-test index 41d0c40..369acdb 100755 --- a/tests/plugin-test +++ b/tests/plugin-test @@ -10,9 +10,8 @@ scripts/cleanup scripts/copy-plugin-confs # enable test-plugin -mv -f ${cwd}/bin/plugins/test-plugin-fd.sox ${cwd}/bin/plugins/test-plugin-fd.so - -mv -f ${cwd}/bin/plugins/bpipe-fd.sox ${cwd}/bin/plugins/bpipe-fd.so +enable_plugin bpipe-fd +enable_plugin test-plugin-fd file=encrypt-bug.jpg echo "${cwd}/README" >${cwd}/tmp/file-list @@ -67,12 +66,9 @@ stop_bareos # # 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 +disable_plugin bpipe-fd cat <${cwd}/tmp/bconcmds -@$out ${cwd}/tmp/log2.out -@# remove plugin -@exec "sh -c 'rm -f ${cwd}/bin/plugins/bpipe-fd.so'" @# @# now do a restore without the plugin @# @@ -110,7 +106,7 @@ stop_bareos # # Restore plugin # -mv -f ${cwd}/bin/plugins/bpipe-fd.sox ${cwd}/bin/plugins/bpipe-fd.so +enable_plugin bpipe-fd check_two_logs # @@ -159,7 +155,5 @@ perl -ne ' estat=$? -# disable test-plugin -mv -f ${cwd}/bin/plugins/test-plugin-fd.so ${cwd}/bin/plugins/test-plugin-fd.sox - end_test +