<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Examples</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>Recent changes to Examples</description><atom:link href="https://sourceforge.net/p/rubycula/wiki/Examples/feed" rel="self"/><language>en</language><lastBuildDate>Thu, 21 Mar 2013 20:05:06 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/rubycula/wiki/Examples/feed" rel="self" type="application/rss+xml"/><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v13
+++ v14
@@ -141,6 +141,8 @@
 Using Ruby 1.8
 =====

+Note that using Ruby 1.8 is deprecated - time to move on! :)
+
 To use Ruby 1.8 and rubygem 'mysql', the beginning of the script has to be modified a bit:

    :::ruby
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Thu, 21 Mar 2013 20:05:06 -0000</pubDate><guid>https://sourceforge.netb2de38d2562eca9a055443f95ebe8b2549d61caa</guid></item><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v12
+++ v13
@@ -7,12 +7,19 @@

     :::ruby
     #!/usr/bin/ruby
-    require_relative "BaculaBase.rb"
-    require_relative "BaculaConf.rb"
-    require_relative "BaculaConfSection.rb"
-    require_relative "BaculaConfMysql.rb"
+    load "BaculaBase.rb"
+    load "BaculaConf.rb"
+    load "BaculaConfSection.rb"
+    load "BaculaConfMysql.rb"
     baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
 &lt;br /&gt;
+
+Update table's reference on the first run (has to be done after updating database structure)
+=====
+
+    :::ruby
+    baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
+    baculaMysql.updateTablesSchema()

 Printing all sections from a DB (eg. for using in bacula-dir.conf)
 =====
@@ -39,10 +46,10 @@

    :::ruby
    #!/usr/bin/ruby
-   require_relative "BaculaBase.rb"
-   require_relative "BaculaConf.rb"
-   require_relative "BaculaConfSection.rb"
-   require_relative "BaculaConfMysql.rb"
+   load "BaculaBase.rb"
+   load "BaculaConf.rb"
+   load "BaculaConfSection.rb"
+   load "BaculaConfMysql.rb"
    baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
    dirConfig = BaculaConf.new(baculaMysql)

@@ -91,9 +98,9 @@

    :::ruby
    #!/usr/bin/ruby
-   require_relative "BaculaBase.rb"
-   require_relative "BaculaConf.rb"
-   require_relative "BaculaConfSection.rb"
+   load "BaculaBase.rb"
+   load "BaculaConf.rb"
+   load "BaculaConfSection.rb"
    dirConfig = BaculaConf.new()

    # prepare to add the 1st job
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Thu, 21 Mar 2013 20:03:59 -0000</pubDate><guid>https://sourceforge.net75872d4b32554c9e343507934f3db6f12abec9ac</guid></item><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;pre&gt;--- v11
+++ v12
@@ -1,6 +1,6 @@
 Here are some code examples for using Rubycula scripts.
 
-Note that in order to preserve the order of configuration parameters within the section, we have to use Ruby 1.9. See how to use Ruby 1.8 [below](#using-ruby-1.8).
+Note that in order to preserve the order of configuration parameters within the section, we have to use Ruby 1.9. See how to use Ruby 1.8 [below](#using-ruby-18).
 
 These lines have to be included at the beginning of every script
 =====
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Fri, 03 Aug 2012 15:29:49 -0000</pubDate><guid>https://sourceforge.net26eb5a569714365e8117eb5a7891548409457b72</guid></item><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;pre&gt;--- v10
+++ v11
@@ -1,16 +1,16 @@
 Here are some code examples for using Rubycula scripts.
 
-Note that in order to preserve the order of configuration parameters within the section, we should use Ruby 1.9, but class BaculaConfMysql can not use 'mysql2' gem yet.
+Note that in order to preserve the order of configuration parameters within the section, we have to use Ruby 1.9. See how to use Ruby 1.8 [below](#using-ruby-1.8).
 
 These lines have to be included at the beginning of every script
 =====
 
     :::ruby
     #!/usr/bin/ruby
-    require "BaculaBase.rb"
-    require "BaculaConf.rb"
-    require "BaculaConfSection.rb"
-    require "BaculaConfMysql.rb"
+    require_relative "BaculaBase.rb"
+    require_relative "BaculaConf.rb"
+    require_relative "BaculaConfSection.rb"
+    require_relative "BaculaConfMysql.rb"
     baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
 &lt;br/&gt;
 
@@ -39,10 +39,10 @@
 
 	:::ruby
 	#!/usr/bin/ruby
-	require "BaculaBase.rb"
-	require "BaculaConf.rb"
-	require "BaculaConfSection.rb"
-	require "BaculaConfMysql.rb"
+	require_relative "BaculaBase.rb"
+	require_relative "BaculaConf.rb"
+	require_relative "BaculaConfSection.rb"
+	require_relative "BaculaConfMysql.rb"
 	baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
 	dirConfig = BaculaConf.new(baculaMysql)
 
@@ -89,10 +89,8 @@
 The same script, but without any SQL
 =====
 
-Note that without BaculaConfMysql we can also use Ruby 1.9.
-
 	:::ruby
-	#!/usr/bin/ruby1.9
+	#!/usr/bin/ruby
 	require_relative "BaculaBase.rb"
 	require_relative "BaculaConf.rb"
 	require_relative "BaculaConfSection.rb"
@@ -132,3 +130,16 @@
 	end
 
 	dirConfig.printSections
+
+Using Ruby 1.8
+=====
+
+To use Ruby 1.8 and rubygem 'mysql', the beginning of the script has to be modified a bit:
+
+	:::ruby
+	#!/usr/bin/ruby
+	require "BaculaBase.rb"
+	require "BaculaConf.rb"
+	require "BaculaConfSection.rb"
+	require "BaculaConfMysql.rb"
+	baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir", "rubygem" =&gt; "mysql"})
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Fri, 03 Aug 2012 15:29:14 -0000</pubDate><guid>https://sourceforge.net0772a91134ba6db7e319f77a4ecc449ddc4767ad</guid></item><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;pre&gt;--- v9
+++ v10
@@ -1,16 +1,16 @@
 Here are some code examples for using Rubycula scripts.
 
-Note that in order to preserve the order of configuration parameters within the section, we have to use Ruby 1.9.
+Note that in order to preserve the order of configuration parameters within the section, we should use Ruby 1.9, but class BaculaConfMysql can not use 'mysql2' gem yet.
 
 These lines have to be included at the beginning of every script
 =====
 
     :::ruby
-    #!/usr/bin/ruby1.9
-    require_relative "BaculaBase.rb"
-    require_relative "BaculaConf.rb"
-    require_relative "BaculaConfSection.rb"
-    require_relative "BaculaConfMysql.rb"
+    #!/usr/bin/ruby
+    require "BaculaBase.rb"
+    require "BaculaConf.rb"
+    require "BaculaConfSection.rb"
+    require "BaculaConfMysql.rb"
     baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
 &lt;br/&gt;
 
@@ -38,11 +38,11 @@
 A more sophisticated example, a full script.
 
 	:::ruby
-	#!/usr/bin/ruby1.9
-	require_relative "BaculaBase.rb"
-	require_relative "BaculaConf.rb"
-	require_relative "BaculaConfSection.rb"
-	require_relative "BaculaConfMysql.rb"
+	#!/usr/bin/ruby
+	require "BaculaBase.rb"
+	require "BaculaConf.rb"
+	require "BaculaConfSection.rb"
+	require "BaculaConfMysql.rb"
 	baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
 	dirConfig = BaculaConf.new(baculaMysql)
 
@@ -89,6 +89,8 @@
 The same script, but without any SQL
 =====
 
+Note that without BaculaConfMysql we can also use Ruby 1.9.
+
 	:::ruby
 	#!/usr/bin/ruby1.9
 	require_relative "BaculaBase.rb"
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Fri, 03 Aug 2012 13:21:35 -0000</pubDate><guid>https://sourceforge.netb2671d861e4b8f6dd3069113aa591e990f3f263b</guid></item><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;pre&gt;--- v8
+++ v9
@@ -1,14 +1,16 @@
 Here are some code examples for using Rubycula scripts.
+
+Note that in order to preserve the order of configuration parameters within the section, we have to use Ruby 1.9.
 
 These lines have to be included at the beginning of every script
 =====
 
     :::ruby
-    #!/usr/bin/ruby
-    require "BaculaBase.rb"
-    require "BaculaConf.rb"
-    require "BaculaConfSection.rb"
-    require "BaculaConfMysql.rb"
+    #!/usr/bin/ruby1.9
+    require_relative "BaculaBase.rb"
+    require_relative "BaculaConf.rb"
+    require_relative "BaculaConfSection.rb"
+    require_relative "BaculaConfMysql.rb"
     baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
 &lt;br/&gt;
 
@@ -35,12 +37,12 @@
 
 A more sophisticated example, a full script.
 
-    :::ruby
-	#!/usr/bin/ruby
-	require "BaculaBase.rb"
-	require "BaculaConf.rb"
-	require "BaculaConfSection.rb"
-	require "BaculaConfMysql.rb"
+	:::ruby
+	#!/usr/bin/ruby1.9
+	require_relative "BaculaBase.rb"
+	require_relative "BaculaConf.rb"
+	require_relative "BaculaConfSection.rb"
+	require_relative "BaculaConfMysql.rb"
 	baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
 	dirConfig = BaculaConf.new(baculaMysql)
 
@@ -88,10 +90,10 @@
 =====
 
 	:::ruby
-	#!/usr/bin/ruby
-	require "BaculaBase.rb"
-	require "BaculaConf.rb"
-	require "BaculaConfSection.rb"
+	#!/usr/bin/ruby1.9
+	require_relative "BaculaBase.rb"
+	require_relative "BaculaConf.rb"
+	require_relative "BaculaConfSection.rb"
 	dirConfig = BaculaConf.new()
 
 	# prepare to add the 1st job
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Fri, 03 Aug 2012 11:31:44 -0000</pubDate><guid>https://sourceforge.netb407103f40f1218d7ae2446d9904090870b164fc</guid></item><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;pre&gt;--- v7
+++ v8
@@ -83,3 +83,48 @@
 	dirConfig = BaculaConf.new(baculaMysql, nil, true)
 	dirConfig.printSections
 &lt;br/&gt;
+
+The same script, but without any SQL
+=====
+
+	:::ruby
+	#!/usr/bin/ruby
+	require "BaculaBase.rb"
+	require "BaculaConf.rb"
+	require "BaculaConfSection.rb"
+	dirConfig = BaculaConf.new()
+
+	# prepare to add the 1st job
+
+	hParamsClient = {"Name" =&gt; "Client-1", "Address" =&gt; "localhost", "Password" =&gt; "changeme", "FD Port" =&gt; 9102}
+	if newClient = dirConfig.sectionCreate("Client", hParamsClient)
+		print "Created new Client!\n"
+	end
+
+	hParamsFileset = {"Name" =&gt; "Fileset-1", "Ignore Fileset Changes" =&gt; "yes"}
+	if newFileset = dirConfig.sectionCreate("Fileset", hParamsFileset)
+		print "Created new Fileset!\n"
+
+		if newFilesetInclude = dirConfig.sectionCreate("Include", {}, false, newFileset)
+			print "Created new Include under Fileset!\n"
+		end
+
+		hParamsFilesetIncludeOptions = {"Compression" =&gt; "GZIP", "Signature" =&gt; "MD5"}
+		if newFilesetIncludeOptions = dirConfig.sectionCreate("Options", hParamsFilesetIncludeOptions, false, newFilesetInclude)
+			print "Created new Options under Include!\n"
+		end
+
+		hParamsFilesetIncludeUpdate = {"File" =&gt; ["/home", "/var"]}
+		# BaculaConf::sectionUpdate(sSection, sectionID, hSectionParams, updateOnly = false)
+		# only add new parameters
+		if dirConfig.sectionUpdate("Include", newFilesetInclude, hParamsFilesetIncludeUpdate, true)
+			print "Updated section Include!\n"
+		end
+	end
+
+	hParamsJob = {"Name" =&gt; "Job-1", "Client" =&gt; newClient.searchParameter("Name"), "Fileset" =&gt; newFileset.searchParameter("Name")}
+	if newJob = dirConfig.sectionCreate("Job", hParamsJob)
+		print "Created new Job!\n"
+	end
+
+	dirConfig.printSections
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Fri, 03 Aug 2012 10:33:30 -0000</pubDate><guid>https://sourceforge.net30cb760fe841ebcf28790832b690479dd7ba90ca</guid></item><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;pre&gt;--- v6
+++ v7
@@ -41,7 +41,7 @@
 	require "BaculaConf.rb"
 	require "BaculaConfSection.rb"
 	require "BaculaConfMysql.rb"
-	baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "baculadirtest", "password" =&gt; "", "database" =&gt; "bacula-dir-test"})
+	baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
 	dirConfig = BaculaConf.new(baculaMysql)
 
 	# prepare to add the 1st job
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Wed, 01 Aug 2012 07:49:35 -0000</pubDate><guid>https://sourceforge.netb50f29f88db72f3372b7fb6423bafea25b745cd6</guid></item><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;pre&gt;--- v5
+++ v6
@@ -4,11 +4,13 @@
 =====
 
     :::ruby
-    require "BaculaConf/BaculaBase.rb"
-    require "BaculaConf/BaculaConf.rb"
-    require "BaculaConf/BaculaConfSection.rb"
-    require "BaculaConf/BaculaConfMysql.rb"
-    baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula", "password" =&gt; "password", "database" =&gt; "bacula-dir"}, false)
+    #!/usr/bin/ruby
+    require "BaculaBase.rb"
+    require "BaculaConf.rb"
+    require "BaculaConfSection.rb"
+    require "BaculaConfMysql.rb"
+    baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "bacula-dir", "password" =&gt; "", "database" =&gt; "bacula-dir"})
+&lt;br/&gt;
 
 Printing all sections from a DB (eg. for using in bacula-dir.conf)
 =====
@@ -26,14 +28,58 @@
     #
     
     @"|/etc/bacula/baculaConf_dir.rb"
+&lt;br/&gt;
 
-Adding new section to DB and updating it
+Adding new client, fileset, job
 =====
 
-Note that here are used section IDs from DB, so they have to exist first.
+A more sophisticated example, a full script.
 
     :::ruby
-    dirConfig = BaculaConf.new(baculaMysql, nil, nil, true, false)
-    jobParameters = {"Client" =&gt; 1, "Fileset" =&gt; 2, "Name" =&gt; "first-job"}
-    newID = dirConfig.sectionCreate("Job", jobParameters)
-    dirConfig.sectionUpdate("job", newID, {"JobDefs" =&gt; 1, "Storage" =&gt; 3, "Type"  =&gt; "Backup"})
+	#!/usr/bin/ruby
+	require "BaculaBase.rb"
+	require "BaculaConf.rb"
+	require "BaculaConfSection.rb"
+	require "BaculaConfMysql.rb"
+	baculaMysql = BaculaConfMysql.new({"host" =&gt; "localhost", "user" =&gt; "baculadirtest", "password" =&gt; "", "database" =&gt; "bacula-dir-test"})
+	dirConfig = BaculaConf.new(baculaMysql)
+
+	# prepare to add the 1st job
+
+	hParamsClient = {"Name" =&gt; "Client-1", "Address" =&gt; "localhost", "Password" =&gt; "changeme", "FD Port" =&gt; 9102}
+	if newClientID = dirConfig.sectionCreate("Client", hParamsClient)
+		print "Created new Client with ID #{newClientID}!\n"
+	end
+
+	hParamsFileset = {"Name" =&gt; "Fileset-1", "Ignore Fileset Changes" =&gt; "yes"}
+	if newFilesetID = dirConfig.sectionCreate("Fileset", hParamsFileset)
+		print "Created new Fileset with ID #{newFilesetID}!\n"
+
+		hParamsFilesetInclude = {"fileset_id" =&gt; newFilesetID}
+		if newFilesetIncludeID = dirConfig.sectionCreate("Include", hParamsFilesetInclude)
+			print "Created new Fileset-Include with ID #{newFilesetIncludeID}!\n"
+		end
+
+		hParamsFilesetIncludeOptions = {"fileset-include_id" =&gt; newFilesetIncludeID, "Compression" =&gt; "GZIP", "Signature" =&gt; "MD5"}
+		if newFilesetIncludeOptionsID = dirConfig.sectionCreate("Options", hParamsFilesetIncludeOptions)
+			print "Created new Fileset-Include-Options with ID #{newFilesetIncludeOptionsID}!\n"
+		end
+
+		hParamsFilesetIncludeUpdate = {"File" =&gt; ["/home", "/var"]}
+		# BaculaConf::sectionUpdate(sSection, sectionID, hSectionParams, updateOnly = false)
+		# only add new parameters
+		if dirConfig.sectionUpdate("Include", newFilesetIncludeID, hParamsFilesetIncludeUpdate, true)
+			print "Updated Fileset-Include with ID #{newFilesetIncludeID}!\n"
+		end
+	end
+
+	hParamsJob = {"Name" =&gt; "Job-1", "Client" =&gt; newClientID, "Fileset" =&gt; newFilesetID}
+	if newJobID = dirConfig.sectionCreate("Job", hParamsJob)
+		print "Created new Job with ID #{newJobID}!\n"
+	end
+
+	# re-read the configuration, use names instead of IDs
+	# BaculaConf::new(configSource = nil, hQuerySections = nil, followForeigns = false, applyTemplates = true, queryTemplatesOnly = false)
+	dirConfig = BaculaConf.new(baculaMysql, nil, true)
+	dirConfig.printSections
+&lt;br/&gt;
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Wed, 01 Aug 2012 07:49:04 -0000</pubDate><guid>https://sourceforge.net2d3192e4831f5479f65c2571d294799ba984e79e</guid></item><item><title>WikiPage Examples modified by Silver</title><link>https://sourceforge.net/p/rubycula/wiki/Examples/</link><description>&lt;pre&gt;--- v4
+++ v5
@@ -18,6 +18,15 @@
     dirConfig = BaculaConf.new(baculaMysql, nil, true, true, false)
     dirConfig.printSections()
 
+This script can very well be the only thing being in Bacula director configuration. bacula-dir.conf could look like this:
+
+
+    #
+    # Default Bacula Director Configuration file
+    #
+    
+    @"|/etc/bacula/baculaConf_dir.rb"
+
 Adding new section to DB and updating it
 =====
 
&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Silver</dc:creator><pubDate>Mon, 30 Jul 2012 09:52:52 -0000</pubDate><guid>https://sourceforge.net848b429bfd584ddea88b5f517d6e4b788ac08caa</guid></item></channel></rss>