Sunday 31 March 2013

Working copies of bacula-sd.conf bacula-fd.conf bacula-dir.conf


Normally after updating the config files, I will let the programs to proof read, checking for syntax errors.  To test the syntax of the config files, you can use:

bacula-sd -t /etc/bacula/bacula-sd.conf
bacula-fd -t /etc/bacula/bacula-fd.conf
bacula-dir -t /etc/bacula/bacula-dir.conf


I have attached below, a working copy of bacula-sd.conf, bacula-fd.conf and bacula-dir.conf.
Below is bacula-sd.conf:

# Default Bacula Storage Daemon Configuration file
#
#  For Bacula release 2.4.4 (28 December 2008) -- redhat Enterprise release
#
# You may need to change the name of your tape drive
#   on the "Archive Device" directive in the Device
#   resource.  If you change the Name and/or the
#   "Media Type" in the Device resource, please ensure
#   that dird.conf has corresponding changes.
#

Storage {                             # definition of myself
  Name = bacula-sd
  SDPort = 9103                  # Director's port
  WorkingDirectory = "/var/spool/bacula"
  Pid Directory = "/var/run"
  Maximum Concurrent Jobs = 20
}
#
# List Directors who are permitted to contact Storage daemon
#
Director {
  Name = bacula-dir
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"
}

#
# Restricted Director, used by tray-monitor to get the
#   status of the storage daemon
#
Director {
  Name = bacula-mon
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"
  Monitor = yes
}

#
# Devices supported by this Storage daemon
# To connect, the Director's bacula-dir.conf must have the
#  same Name and MediaType.
#

Device {
  Name = FileStorage
  Media Type = File
  Archive Device =/bacula-backup
  LabelMedia = yes;                   # lets Bacula label unlabeled media
  Random Access = Yes;
  AutomaticMount = yes;               # when device opened, read it
  RemovableMedia = no;
  AlwaysOpen = no;
}

#
# Send all messages to the Director,
# mount messages also are sent to the email address
#

Messages {
  Name = Standard
  director = bacula-dir = all
}

Attached below is a working copy of bacula-fd.conf.
#
# Default  Bacula File Daemon Configuration file
#
#  For Bacula release 2.4.4 (28 December 2008) -- redhat Enterprise release
#
# There is not much to change here except perhaps the
# File daemon Name to
#

#
# List Directors who are permitted to contact this File daemon
#
Director {
  Name = bacula-dir
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"
}
#
# Restricted Director, used by tray-monitor to get the
#   status of the file daemon
#
Director {
  Name = bacula-mon
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"
  Monitor = yes
}
#
# "Global" File daemon configuration specifications
#
FileDaemon {                          # this is me
  Name = bacula-fd
  FDport = 9102                  # where we listen for the director
  WorkingDirectory = /var/spool/bacula
  Pid Directory = /var/run
  Maximum Concurrent Jobs = 20
}
# Send all messages except skipped files back to Director
Messages {
  Name = Standard
  director = bacula-dir = all, !skipped, !restored
}

Attached below is bacula-dir.conf.
#
# Default Bacula Director Configuration file
#
#  The only thing that MUST be changed is to add one or more
#   file or directory names in the Include directive of the
#   FileSet resource.
#
#  For Bacula release 2.4.4 (28 December 2008) -- redhat Enterprise release
#
#  You might also want to change the default email address
#   from root to your address.  See the "mail" and "operator"
#   directives in the Messages resource.
#

Director {                            # define myself
  Name = bacula-dir
  DIRport = 9101                # where we listen for UA connections
  QueryFile = "/etc/bacula/query.sql"
  WorkingDirectory = "/var/spool/bacula"
  PidDirectory = "/var/run"
  Maximum Concurrent Jobs = 1
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"         # Console password
  Messages = Daemon
}

#################################################################
#     Backup for RHEL5_59                                       #
#################################################################
# Define the main nightly save backup job
#   By default, this job will back up to disk in
Job {
  Name = "RHEL5_59"
  Write Bootstrap = "/var/spool/bacula/%c_%n.bsr"
  Type = Backup
  Client = RHEL5_59
  FileSet = "RHEL5_59"
  Schedule = "RHEL5_59"
  Storage = File
  Messages = Standard
  Pool = Default
  Priority = 10
}

# List of files to be backed up
FileSet {
  Name = "RHEL5_59"
  Include {
    Options {
      signature = MD5
    }
    File = /etc
  }

#
# If you backup the root directory, the following two excluded
#   files can be useful
#
#  Exclude {
#    File = /proc
#    File = /tmp
#    File = /.journal
#    File = /.fsck
#  }
}

#
# When to do the backups, full backup on first sunday of the month,
#  differential (i.e. incremental since full) every other sunday,
#  and incremental backups other days
Schedule {
  Name = "RHEL5_59"
  Run = Full 1st sun at 20:26
  Run = Differential 2nd-5th sun at 20:26
  Run = Incremental mon-sat at 20:26
}

# Client (File Services) to backup
Client {
  Name = RHEL5_59
  Address = localhost
  FDPort = 9102
  Catalog = MyCatalog
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"          # password for FileDaemon
  File Retention = 30 days            # 30 days
  Job Retention = 6 months            # six months
  AutoPrune = yes                     # Prune expired Jobs/Files
}

#################################################################
#     Backup for F18_23                                         #
#################################################################
# Define the main nightly save backup job
#   By default, this job will back up to disk in
Job {
  Name = "F18_23"
  Write Bootstrap = "/var/spool/bacula/%c_%n.bsr"
  Type = Backup
  Client = F18_23
  FileSet = "F18_23"
  Schedule = "F18_23"
  Storage = File
  Messages = Standard
  Pool = Default
  Priority = 10
}

# List of files to be backed up
FileSet {
  Name = "F18_23"
  Include {
    Options {
      signature = MD5
    }
    File = /etc
    File = /var/www/
  }

#
# If you backup the root directory, the following two excluded
#   files can be useful
#
#  Exclude {
#    File = /proc
#    File = /tmp
#    File = /.journal
#    File = /.fsck
#  }
}

#
# When to do the backups, full backup on first sunday of the month,
#  differential (i.e. incremental since full) every other sunday,
#  and incremental backups other days
Schedule {
  Name = "F18_23"
  Run = Full 1st sun at 20:26
  Run = Differential 2nd-5th sun at 20:26
  Run = Incremental mon-sat at 20:26
}

# Client (File Services) to backup
Client {
  Name = F18_23
  Address = 192.168.0.23
  FDPort = 9102
  Catalog = MyCatalog
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"          # password for FileDaemon
  File Retention = 30 days            # 30 days
  Job Retention = 6 months            # six months
  AutoPrune = yes                     # Prune expired Jobs/Files
}
#################################################################
#     Backup for CENTOS6                                        #
#################################################################
# Define the main nightly save backup job
#   By default, this job will back up to disk in
Job {
  Name = "CENTOS6_38"
  Write Bootstrap = "/var/spool/bacula/%c_%n.bsr"
  Type = Backup
  Client = CENTOS6_38
  FileSet = "CENTOS6_38"
  Schedule = "CENTOS6_38"
  Storage = File
  Messages = Standard
  Pool = Default
  Priority = 10
}

# List of files to be backed up
FileSet {
  Name = "CENTOS6_38"
  Include {
    Options {
      signature = MD5
    }
    File = /etc
    File = /var/www/
  }

#
# If you backup the root directory, the following two excluded
#   files can be useful
#
#  Exclude {
#    File = /proc
#    File = /tmp
#    File = /.journal
#    File = /.fsck
#  }
}

#
# When to do the backups, full backup on first sunday of the month,
#  differential (i.e. incremental since full) every other sunday,
#  and incremental backups other days
Schedule {
  Name = "CENTOS6_38"
  Run = Full 1st sun at 20:26
  Run = Differential 2nd-5th sun at 20:26
  Run = Incremental mon-sat at 20:26
}
# Client (File Services) to backup
Client {
  Name = CENTOS6_38
  Address = 192.168.0.38
  FDPort = 9102
  Catalog = MyCatalog
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"          # password for FileDaemon
  File Retention = 30 days            # 30 days
  Job Retention = 6 months            # six months
  AutoPrune = yes                     # Prune expired Jobs/Files
}

#################################################################
#     Backup for Catalog on RHEL5_59                            #
#################################################################

# Backup the catalog database (after the nightly save)
Job {
  Name = "BackupCatalog"
  Level = Full
  FileSet="Catalog"
  Schedule = "WeeklyCycleAfterBackup"
  # This creates an ASCII copy of the catalog
  # Arguments to make_catalog_backup.pl are:
  #  make_catalog_backup.pl 
  RunBeforeJob = "/usr/libexec/bacula/make_catalog_backup.pl MyCatalog"
  # This deletes the copy of the catalog
  RunAfterJob  = "/usr/libexec/bacula/delete_catalog_backup"
  Write Bootstrap = "/var/spool/bacula/%c_%n.bsr"
  Priority = 11                   # run after main backup

  Type = Backup
  Client = RHEL5_59
  Storage = File
  Messages = Standard
  Pool = Default
}

# This is the backup of the catalog
FileSet {
  Name = "Catalog"
  Include {
    Options {
      signature = MD5
    }
    File = /var/spool/bacula/bacula.sql
  }
}

# This schedule does the catalog. It starts after the WeeklyCycle
Schedule {
  Name = "WeeklyCycleAfterBackup"
  Run = Full sun-sat at 23:10
}


#
# Standard Restore template, to be changed by Console program
#  Only one such job is needed for all Jobs/Clients/Storage ...
#
Job {
  Name = "RestoreFiles"
  Type = Restore
  Client=RHEL5_59
  FileSet="RHEL5_59"
  Storage = File
  Pool = Default
  Messages = Standard
  Where = /bacula-restores
}

# Definition of file storage device
Storage {
  Name = File
  Address = localhost                # N.B. Use a fully qualified name here
  SDPort = 9103
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"
  Device = FileStorage
  Media Type = File
}
# Generic catalog service
Catalog {
  Name = MyCatalog
  dbname = "bacula"; dbuser = "bacula"; dbpassword = ""
}

# Reasonable message delivery -- send most everything to email address
#  and to the console
Messages {
  Name = Standard
#
# NOTE! If you send to two email or more email addresses, you will need
#  to replace the %r in the from field (-f part) with a single valid
#  email address in both the mailcommand and the operatorcommand.
#  What this does is, it sets the email address that emails would display
#  in the FROM field, which is by default the same email as they're being
#  sent to.  However, if you send email to more than one address, then
#  you'll have to set the FROM address manually, to a single address.
#  for example, a 'no-reply@mydomain.com', is better since that tends to
#  tell (most) people that its coming from an automated source.

#
  mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: %t %e of %c %l\" %r"
  operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bacula\) \<%r\>\" -s \"Bacula: Intervention needed for %j\" %r"
  mail = root@localhost = all, !skipped
  operator = root@localhost = mount
  console = all, !skipped, !saved
# Default pool definition
Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes                       # Bacula can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days         # one year
  Label Format = "File-"
}

# Scratch pool definition
Pool {
  Name = Scratch
  Pool Type = Backup
}

#
# Restricted console used by tray-monitor to get the status of the director
#
Console {
  Name = bacula-mon
  Password = "d84c7934a7a786d26da3d34d5f7c6c86"
  CommandACL = status, .status
}

Tuesday 26 March 2013

Compare php 5.3 vs 5.4

How much faster is php5.4 compared to php5.3? It was benchmarked , 5.4 is almost twice as fast as 5.3. PHP 5.4 significantly improves performance, memory footprint and fixes over 100 bugs.

PHP 5.4.0 offers a wide range of new features:

Support for traits has been added.
Short array syntax has been added, e.g. $a = [1, 2, 3, 4]; or $a = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => 4];.
Function array dereferencing has been added, e.g. foo()[0].
Closures now support $this.
<?= is now always available, regardless of the short_open_tag php.ini option.
Class member access on instantiation has been added, e.g. (new Foo)->bar().
Class::{expr}() syntax is now supported.
Binary number format has been added, e.g. 0b001001101.
Improved parse error messages and improved incompatible arguments warnings.
The session extension can now track the upload progress of files.
Built-in development web server in CLI mode.

Raspberry Pi


It has a TV out and an HDMI Port. I don't know any family without a TV (well very few, but they don't have a TV by choice and not because they can't afford one, however they have a computer and therefore a computer display). RasPi is a UK Company. The European community is regulating cellphone chargers. They must use an USB Micro-B connector (with 800-1000 mA output). Guess what? This is also the sort of power supply the RasPi needs. Since most Europeans get a new cellphone every 1-2 years, these chargers are disposable (every new phone comes with a new charger even though the old one is still working perfectly). So display available, check. Power supply available, check. Now all we need is an SD card, a Keyboard and a mouse (USB). A cheap keyboard and a cheap mouse would not cost more than 15 us dollars. And if I were a smart kid, I'd ask family and friends if I could buy used ones (which I probably would get donated). Nearly all families already have a mac or windows pc (but might not want their children to break it while experimenting) mouse and keyboard could be used from the already available computer. Well, now we have only one item left that is missing, the SD card. Many digital cameras are replaced here with smart phones. It's not the same but I see those aging cameras laying around in many house holds. Guess what, they often use SD cards. But since the SD card needs to be reformatted and somewhat inserted permanently into the device, it might be reasonable to buy a separate one. This leaves us with one extra expense: a new SD card for $20-30, big deal! I personally think the RasPi team has a very neat design there, don't you?

Upgrade mysql (5.1) to mysql55 on CENTOS6

To upgrade from mysql (default ver 5.1) to mysql55 (IUS ver 5.5):

Replace residual mysql component to mysql55:
[root@localhost ~]# yum replace mysql-libs --replace-with mysql55


Install server and client:
[root@localhost ~]# yum install mysql55-server mysql55


Start server upon reboot:
[root@localhost ~]# chkconfig mysqld on 


Start server service:
[root@localhost ~]# service mysqld start


Change root password:
[root@localhost ~]# mysqladmin -u root password

Upgrade php53u to php54 on CENTOS5

To upgrade php53/php53u to php54 on CENTOS5.

Enable IUS and EPEL:

[root@example ~]# rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/CentOS/5/x86_64/ius-release-1.0-10.ius.centos5.noarch.rpm
[root@example ~]# rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/CentOS/5/x86_64/epel-release-5-4.noarch.rpm


Install yum replace plugin:
[root@example ~]# yum install yum-plugin-replace
Upgrade php53 to php4:
[root@example ~]# yum replace php53u --replace-with php54
Verify php version:
[root@example ~]# php -v
Restart httpd:
[root@example ~]# service httpd restart

Monday 25 March 2013

Installing Bacula Console (Gnome) on CENTOS5

If you are using Gnome Desktop, you can access Bacula using Bacula Console (Gnome)

Below are the installation steps:

[root@example bacula-web]# yum install bacula-console-gnome


Change the director ipaddress and password

[root@example bacula-web]# vi /etc/bacula/bgnome-console.conf



Director {

  Name = bacula-dir

  DIRport = 9101

  address = localhost

  Password = "d84c7934a7a7826da3d34d5f7c6c86"

}



ConsoleFont {

  Name = Default

  Font = "LucidaTypewriter 9"

}

Installing Bacula-Web on CENTOS5


Bacula-Web is a monitoring and reporting web gui for Bacula.

[root@example html]# cd /var/www/html/

[root@example html]# yum install php54-common php54-pear php54-pdo php54 php54-gd php54-cli php54-pecl-apc php54-mysql  

[root@example html]# mkdir bacula-web

[root@example html]# cd bacula-web

[root@example bacula-web]# wget http://www.bacula-web.org/tl_files/downloads/bacula-web-5.2.12.tar.gz

[root@example bacula-web]# tar -xzvf bacula-web-5.2.12.tar.gz

[root@example bacula-web]# cd ..

[root@example html]# chown -Rv apache:apache ./bacula-web

[root@example html]# chmod -Rv u=rx,g=rx,o=rx ./bacula-web

[root@example html]# chmod -v ug+w ./bacula-web/application/view/cache

[root@example config]# cd ./bacula-web/application/config

[root@example config]# cp -v config.php.sample config.php

[root@example config]# chown -v apache: config.php

[root@example config]# vi config.php


To test your installation of Bacula-Web, follow this link:

http://ipaddress/bacula-web/test.php

To goto the web:

http://ipaddress/bacula-web

Sunday 24 March 2013

Installing Bacula on CENTOS5

Installing Bacula on CENTOS5 using YUM package-management utility. You have to have root access to install and run Bacula properly. A database server (eg MySQL) is needed to manage backup details. In this case, you will need mysql root access (ie MySQL root password). In this guide, it is assumed that the Bacula Director,File daemon,Storage daemon are installed in the same computer/server. When you want to backup across more computers/servers, just need to declare more clients and update the addresses.

Bacula is an Open Source Network Backup program that allows system admin to backup, recover data from servers and computer. More details can be obtained from its official website. (http://www.bacula.org/en)

Lets start with the yum install:

yum install bacula-client bacula-director-mysql bacula-storage-mysql bacula-traymonitor bacula-common bacula-director-common bacula-storage-common bacula-console


YUM will then go thru the dependency and add additional packages to install. Enter 'y' to proceed to install all required packages.

Is this ok [y/N]: y


Run below scripts to create and link mysql tables to Bacula:

/usr/libexec/bacula/grant_mysql_privileges -uroot -p
/usr/libexec/bacula/create_mysql_database -uroot -p
/usr/libexec/bacula/make_mysql_tables -uroot -p
/usr/libexec/bacula/grant_bacula_privileges -uroot -p
The Bacula is made up of 4 basic components: Director, File daemon(FD), Storage daemon(SD),Console programs. For security, lets change their default password. To generate a password hash:

[root@example ~]# echo "mypassword" |md5sum
d84c7934a7a786d26da3d34d5f7c6c86  -

For simplicity, I am using the above password hash to all password fields in below config files:

vi /etc/bacula/bacula-dir.conf
vi /etc/bacula/bacula-fd.conf
vi /etc/bacula/bacula-sd.conf
vi /etc/bacula/bconsole.conf
vi /etc/bacula/tray-monitor.conf

The default storage location is in /tmp. To change to another directory:

mkdir /bacula-backup


vi /etc/bacula/bacula-sd.conf

change

Archive Device = /tmp


to

Archive Device = /bacula-backup

To update the address of the file daemon:
vi /etc/bacula/bacula-dir.conf

Client {
  Name = bacula-fd
  Address = client.example.com
  FDPort = 9102
  Catalog = MyCatalog

To

Client {
  Name = bacula-fd
  Address = localhost
  FDPort = 9102
  Catalog = MyCatalog


and


Storage {

  Name = File

# Do not use "localhost" here

  Address = XXXXXXXXXX                # N.B. Use a fully qualified name here

  SDPort = 9103


To
Storage {

  Name = File

# Do not use "localhost" here

  Address = localhost                # N.B. Use a fully qualified name here

  SDPort = 9103

(Yes, the comments says do not use "localhost" and I used it. You can replace the address with a FQDN that is used as Bacula backup server.)

To enable the services:
chkconfig bacula-sd on

chkconfig bacula-fd on

chkconfig bacula-dir on


To turn on the services:
service bacula-fd start

service bacula-sd start

service bacula-dir start


To create volumes, run:
[root@example ~]# bconsole
Connecting to Director localhost:9101
1000 OK: bacula-dir Version: 2.4.4 (28 December 2008)
Enter a period to cancel a command.
*label
Automatically selected Catalog: MyCatalog
Using Catalog "MyCatalog"
Automatically selected Storage: File
Enter new Volume name: vol
Defined Pools:
     1: Default
     2: Scratch
Select the Pool (1-2): 1
Connecting to Storage daemon File at localhost:9103 ...
Sending label command for Volume "vol" Slot 0 ...
3000 OK label. VolBytes=195 DVD=0 Volume="vol" Device="FileStorage" (/bacula-backup)
Catalog record for Volume "vol", Slot 0  successfully created.
Requesting to mount FileStorage ...
3906 File device "FileStorage" (/bacula-backup) is always mounted.

search iomeweekly