For introduction and working to bacula Please visit:
http://www.bacula.org/en/dev-manual/main/main/What_is_Bacula.html
Login as root
sudo -i Enter password
Installation
apt-get install bacula-server bacula-console
Editing bacula-dir.conf file.
To edit This file:
vi /etc/bacula/bacula-dir.conf
Define your bacula director here: keep the parameter Name = director-name and Password = “dir-password” in mind as this is to be used in all the configuration files. Comment DirAddress=127.0.0.1
# Default Bacula Director Configuration file
Director { # define myself Name = director-name DIRport = 9101 QueryFile = “/etc/bacula/scripts/query.sql” WorkingDirectory = “/var/lib/bacula” PidDirectory = “/var/run/bacula” Maximum Concurrent Jobs = 1 Password = “dir-password” Messages = Daemon # DirAddress = 127.0.0.1 }
These are the client configuration files stored at the following location.
This is a backup job file.
@/etc/bacula/clients/backupjob.conf
This is a restore job file.
@/etc/bacula/clients/restorejob.conf
We define storage device parameters here. This is the storage device that bacula uses to store backups. Name = storage-sd, Address = 10.28.79.159 and Password field are needed to edit here. Storage name is important as same name should be used while defining a job.
# Definition of file storage device
Storage { Name = storage-sd # Do not use “localhost” here Address = 10.28.79.159 SDPort = 9103 Password = “dir-password” Device = FileStorage Media Type = File }
Define a catalog and database parameters here
# Generic catalog service
Catalog { Name = MyCatalog # Uncomment the following line if you want the dbi driver # dbdriver = “dbi:sqlite3″; dbaddress = 127.0.0.1; dbport = dbname = bacula; DB Address = “”; dbuser = “bacula”; dbpassword = “word2pass” }We will use Default pool. The parameter Name = Default is to be defined in jobs.
# Default pool definition
Pool { Name = Default Pool Type = Backup Recycle = yes AutoPrune = yes Volume Retention = 365 days } # File Pool definition Pool { Name = mypool Pool Type = Backup Recycle = yes AutoPrune = yes Volume Retention = 365 days Maximum Volume Bytes = 50G Maximum Volumes = 100 }
Editing bacula-fd.conffile.
To edit This file:
vi /etc/bacula/bacula-fd.conf
The Name and Password will remain same as we defined in /etc/bacula/bacula-dir.conf
# List Directors who are permitted to contact this File daemon Director { Name = director-name Password = “dir-password” } Important Parameter here is Name of filedaemon. # “Global” File daemon configuration specifications FileDaemon { Name = filedaemon-name FDport = 9102 WorkingDirectory = /var/lib/bacula Pid Directory = /var/run/bacula Maximum Concurrent Jobs = 20 # FDAddress = 127.0.0.1 } # Send all messages except skipped files back to Director Messages { Name = Standard director = director-name = all, !skipped, !restored }
Edit bacula-sd.conf file.
To edit This file:
vi /etc/bacula/bacula-sd.conf
# Default Bacula Storage Daemon Configuration file
Important parameters are Name, it should be same as we defined in bacula-dit.conf and SDAddress should be commented out.
Storage { Name = storage-sd SDPort = 9103 WorkingDirectory = “/var/lib/bacula” Pid Directory = “/var/run/bacula” Maximum Concurrent Jobs = 20 # SDAddress = 127.0.0.1 }
Once again define the director here. Name and Password will remain same as we did in bacula-dir.conf
# List Directors who are permitted to contact Storage daemon Director { Name = director-name Password = “dir-password” } # Devices supported by this Storage daemon
Important parameter here are Archive Device this is where all the backup volumes will be stored, Define a path that should have space and appropriate permissions and change AlwaysOpen to yes.
Device { Name = FileStorage Media Type = File Archive Device = /backups LabelMedia = yes; Random Access = Yes; AutomaticMount = yes; RemovableMedia = no; AlwaysOpen = yes; }BackupJob Definitions.
I created a directory clients in /etc/bacula and stored backup and retore jobs.
vi /etc/bacula/clients/backupjob.conf
The Important parameters are Name, Address, Catalog, Password. Use dir-password here in Password parameter . Get IP of the client to fill in Address parameter and Name should match while defining the Job parameters. Catalog was defined in bacula-dir.conf file, we will use same Catalog.
Client {
Name = client-name
Address = IP address of the client to be backed up
FDPort = 9102
Catalog = MyCatalog
Password = “dir-password”
File Retention = 30 days
Job Retention = 6 months
AutoPrune = yes
}
The File set contains the file while are to be backed up. Name and File parameters are important here. Name parameter is to be used while defining Job. And Files define the path of client directory which is to be backed up.
FileSet {
Name = “file-set”
Include {
Options {
signature = MD5
}
File = /htdocs
}
}
This is Job definition. Copy client-name from Client Definition, FileSet from FileSet Definition and Storage should be same as we defined in bacula-dir.conf. Type can be Backup/Restore. We are defining this job for backup right now. Pool will Default. Write Bootstrap File should exist at the path defined.
Job {
Name = Job-Name
Type = Backup
Client = client-name
FileSet = “file-set”
Storage = storage-sd
Pool = Default
Messages = Standard
Write Bootstrap = “/var/lib/bacula/mybootstrap.bsr”
}
RestoreJob Definitions.
I created a directory clients in /etc/bacula and stored backup and retore jobs.
vi /etc/bacula/clients/restorejob.conf
Restore Job definition will remain same as we did in backupjob but two parameters Type will be Restore and Where defines the location of restoration of files from backup volume.
Job {
Name = “restore job”
Type = Restore
Client = client-name
FileSet = “file-set”
Storage = storage-sd
Pool = Default
Messages = Standard
Where = /
# JobDefs = “FullBackupJob”
Write Bootstrap = “/var/lib/bacula/mybootstrap.bsr”
}
Edit bacula-fd.conf on client side.
vi /etc/bacula/bacula-fd.conf
Define director parameters. Same as we did in /etc/bacula/bacula-dir.conf.
# List Directors who are permitted to contact this File daemon
Director {
Name = director-name
Password = “dir-password”
}
The parameter FDAddress is to be commented out.
# “Global” File daemon configuration specifications
FileDaemon {
Name = filedaemon-name
FDport = 9102
WorkingDirectory = /var/lib/bacula
Pid Directory = /var/run/bacula
Maximum Concurrent Jobs = 10
# FDAddress = 127.0.0.1
}
# Send all messages except skipped files back to Director
Messages {
Name = Standard
director = director-name = all, !skipped, !restored
}
Now edit bconsole.conf
vi /etc/bacula/bconsole.conf
Director {
Name = director-name
DIRport = 9101
address = IP address of bacula server
Password = “dir-password”
}
Run bconsole and enter the following commands
bconsole
root@farhan:/usr/share/php/libzend-framework-php# bconsole
Connecting to Director 10.28.79.159:9101
1000 OK: nxb-dir Version: 5.0.1 (24 February 2010)
Enter a period to cancel a command.
*label
Automatically selected Catalog: MyCatalog
Using Catalog “MyCatalog”
Automatically selected Storage: nxb-sd
Enter new Volume name: nxb-sd
Defined Pools:
1: Default
2: File
3: Scratch
Select the Pool (1-3): 1
Connecting to Storage daemon nxb-sd at 10.28.79.159:9103 …
Sending label command for Volume “nxb-sd” Slot 0 …
3000 OK label. VolBytes=190 DVD=0 Volume=”nxb-sd” Device=”FileStorage” (/backups)
Catalog record for Volume “nxb-sd”, Slot 0 successfully created.
Requesting to mount FileStorage …
3001 OK mount requested. Device=”FileStorage” (/backups)
Webacula – Web based administration of bacula
Installation and configuration.
install apache and php libraries if not installed already other wise skip installation
apt-get install apache2 php5 libapache2-mod-php5 php5-mysql php5-gd
check of php is enabled
a2enmod php5
enable apache rewrite mod
a2enmod rewrite
create a dir in /var/www/webacula where webaula files will be stored
mkdir /var/www/webacula
cd /var/www/webacula
download webacula
wget -c http://dfn.dl.sourceforge.net/project/webacula/webacula/5.0.2/webacula-5.0.2.tar.gz
extract the downloaded application
tar -zxvf webacula-5.0.2.tar.gz
cd webacula-5.0.2
moving all the content of application from extracted dir to webacula
mv /var/www/webacula-5.0.2/* /var/www/webacula
change the ownership of webacula directory to apache user ‘www-data’.
chown -R www-data:www-data /var/www/webacula
check the requirements and in case some of the requirements are missing install the required libraries.
apt-get install php5-cli
apt-get install php5-pgsql
sudo apt-get install libtool
php5 /var/www/webacula/install/check_system_requirements.php
Check System Requirements…
Current MySQL version = 5.0.51 OK
Current PHP version = 5.2.4-2ubuntu5.6 OK
php pdo installed. OK
php gd installed. OK
php xml installed. OK
php dom installed. OK
php pdo_mysql installed. OK
Warning. php pdo_pgsql extension not installed.
php-dom, php-xml installed. OK
install zend framework
apt-get install zend-framework
modify config.ini file of webacula.
vi /var/www/webacula/application/config.ini
in the general section add root user and passwd of mysql
[general]
db.adapter = PDO_MYSQL
db.config.host = localhost
db.config.username = root
db.config.password = word2pass
db.config.dbname = bacula
tmpdir = “/tmp”
These are the paths how bconsole is accessed from webacula. make sure that paths are correct.
bacula.sudo = “/usr/bin/sudo”
bacula.bconsole = “/usr/bin/bconsole”
bacula.bconsolecmd = “-n -c /etc/bacula/bconsole.conf”
This part of config.ini contains how webcula and sql are connected.
[webacula]
db.adapter = PDO_MYSQL
; db.adapter = PDO_PGSQL
db.config.host = localhost
db.config.username = wbuser
db.config.password = wbpass
db.config.dbname = webacula
change the group of bacula to www-data
usermod -aG bacula www-data
check the group of user bacula
cat /etc/group | grep bacula
output:
bacula:x:125:www-data
change the ownership and permissions of following
chown root:bacula /usr/bin/bconsole
chmod 750 /usr/bin/bconsole
chown root:bacula /etc/bacula/bconsole.conf
chmod 640 /etc/bacula/bconsole.conf
create a virtual host for webacula
vi /etc/apache2/sites-available/webacula
Alias “/webacula” “/var/www/webacula/html”
<directory “/var/www/webacula/html”>
Options Indexes FollowSymLinks
AllowOverride All
Order deny,allow
Allow from All
Allow from 192.168.1.0/255.255.255.0
AuthType Basic
AuthName “Webacula”
AuthUserFile /etc/apache2/webacula.users
Require valid-user
</directory>
enable site webacula and reload apache.
a2ensite webacula
/etc/init.d/apache2 reload
add a apache user that can login webacula
htpasswd -c /etc/apache2/webacula.users admin
New password:
Re-type new password:
edit your htaccess file to look like this.
vi /var/www/webacula/html/.htaccess
php_flag magic_quotes_gpc off
php_flag register_globals off
RewriteEngine On
RewriteBase /webacula
RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Reload Apache
/etc/init.d/apache2 reload
apachectl -t -D DUMP_MODULES 2>&1 | grep rewrite
rewrite_module (shared)
Login into mysql and create user, databases and give privileges.
mysql -u root -p
CREATE USER ‘wbuser’@’localhost’ IDENTIFIED BY ‘wbpass’;
GRANT ALL PRIVILEGES ON *.* TO ‘webacula’@’localhost’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit
edit ‘webacula_mysql_create_database.sh’ and enter the mysql information in the file.
vi /var/www/webacula/install/webacula_mysql_create_database.sh
db_user=”wbuser”
db_password=”wbpass”
host=”localhost”
add a line in visudo file for this
visudo
copy the line below and paste in the next line to “root ALL=(ALL) ALL”
www-data ALL=NOPASSWD: /usr/bin/bconsole
Restart Services
service bacula-director restart
service bacula-fd restart
service bacula-sd restart
Acess URL:
http://server.address/webacula
enter username and password of apache user ‘admin’.
If got zend framework include error add this line to php.ini and restart apache
vi /etc/php5/apache2/php.ini
include_path=”/usr/share/php/libzend-framework-php/”
service apache2 restart
Default ports 9101, 9102 and 9103 are used for bacula-director, bacula-fd and bacula-sd respectively in this tutorial
director-name should remain in bacula-dir.conf, bacula-fd.conf, bacula-sd.conf and client side bacula-fd.conf.
director-password should remain in bacula-dir.conf, bacula-fd.conf, bacula-sd.conf, backupjob.conf and client side bacula-fd.conf.
storage-sd should remain in bacula-dir.conf, bacula-sd.conf, backupjob.conf and restorejob.conf
MyCatalog should remain same in bacula-dir.conf and backupjob.conf
Default(pool) should remain same in bacula-dir.conf, backupjob.conf and restorejob.conf
client-name and file-set should remain same in backupjob.conf and restorejob.conf
Missing Installations
apt-get install php4-dev
apt-get install php5-pgsql
apt-get install php-pear
http://info4admins.com/ubuntu-installing-zend-framework-with-netbeans/
References
http://askubuntu.com/questions/19317/allow-user-to-sudo-a-script-without-password
Your MySQL connection id is 178
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)
mysql> CREATE USER ‘wbuser’@’localhost’ IDENTIFIED BY ‘wbpass’;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘wbpass’’ at line 1
Thanks for the great step by step. Do you have any suggestions for this syntax not working in mysql?
i will suggest instead of copy pasting the query write it down manually This is the issue with the quotes ”. Manually putting the query will work fine Thanks
Thanks. Using ‘ worked better than using `
mysql> CREATE USER wbuser IDENTIFIED BY wbpass;
Aaron please elaborate what is wrong with mentioned MySql Query
Hi fan0o, thank you for this guide, very detailed. I have a problem at the end: when I try to reach my new webserver, instead of the login page, I can only see the folder stuff like an ftp server.
Can you help me?
Best regards
Terafil