GettingStarted

Silver

0. Install rubygem-mysql2 (for ruby 1.9)

1. Get the code:

svn checkout svn://svn.code.sf.net/p/rubycula/code/BaculaConf/trunk rubycula
cd rubycula



2. Create database:

mysql -e 'CREATE DATABASE `bacula-dir`'
mysql -e 'GRANT ALL PRIVILEGES ON `bacula-dir`.* TO `bacula-dir`@localhost'
mysql -u bacula-dir bacula-dir < bacula-dir.sql



3. Create the 1st script using Rubycula, eg. bacula.rb:

#!/usr/bin/ruby
load "BaculaBase.rb"
load "BaculaConf.rb"
load "BaculaConfSection.rb"
load "BaculaConfMysql.rb"
baculaMysql = BaculaConfMysql.new({"host" => "localhost", "user" => "bacula-dir", "password" => "", "database" => "bacula-dir"})
# has to be run only once (on the 1st usage of the database)
baculaMysql.updateTablesSchema()

dirConfig = BaculaConf.new(baculaMysql)

# add the 1st client
hParams = {"Name" => "Client-1", "Address" => "localhost", "Password" => "changeme", "FD Port" => 9102}
newID = dirConfig.sectionCreate("Client", hParams)
print "Created new Client with ID #{newID}!\n"



4. Run the script:

chmod 755 bacula.rb
./bacula.rb



See more examples here: [Examples].


Related

Wiki: Examples
Wiki: Home

Discussion


Anonymous

Cancel  Add attachments