Bareos on Arch linux – part I – Installation

bareos-full-logo

About Bareos


Bareos
Backup Archiving REcovery Open Source is a 100% open source fork of the backup project from BACULA. The fork is in development since late 2010, and of-course, it has a lot of new features like Bacula.

Bareos is made up of the following five major components or services: Director, Console, File, Storage, and Monitor services.

In this tutorial, we will be installing Bareos backup system and all of its components in Arch Linux .

STEP 1 – Install MariaDB database

Install the database depend on what type you want to use with Bareos.

In this tutorial, we will use MariaDB.

To install MariaDB, run the following command:

$ sudo pacman -Sy mariadb mariadb-clients libmariadbclient

Initialize MariaDB data directory:

$ sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Enable MariaDB at startup and start it:

$ sudo systemctl enable mysqld
$ sudo systemctl start mysqld

Secure MariaDB:

$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):    
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n]     
New password:                 //type root password for MySQL           
Re-enter new password:       // re-type password
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n]
... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n]
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n]
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n]
... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

STEP 2 – Install Bareos

At this time Bareos si available only from AUR. The best way is use yaourt to install it.

Enable archlinuxfr repository at /etc/pacman.conf:

$ sudo nano /etc/pacman.conf

and add at the end new repository:

[archlinuxfr]
Server = http://repo.archlinux.fr/$arch

Install yaourt:

$ sudo pacman -Sy yaourt

Bareos consist of some important parts – Director, Storage, Catalog, Client and to each of them there is  corresponding package we have to install – bareos-director, bareos-filedaemon, bareos-storage, bareos-database-common, bareos-database-mysql, bareos-bat, bareos-common, bareos-bconsole. Each part can have some plugins.

The best way is to install bareos-common which will install provide other packages

$ yaourt -Sy bareos-common
==> Edit PKGBUILD ? [Y/n] ("A" to abort)
==> ------------------------------------
==> n            //choose N we do not need to edit PKBUILD

==> WARNING: This PKGBUILD describes a split package.
==> Specific package options are unknown
==> bareos dependencies:
- sqlite (already installed)
- libmariadbclient (already installed)
- postgresql-libs (already installed)
==> Continue building bareos-common ? [Y/n]
==> ---------------------------------------
==>            //choose Y or simply hit ENTER    
==> Building and installing package
==> This PKGBUILD provides " bareos-common bareos-bconsole bareos-database-common bareos-database-mysql 
bareos-database-postgresql bareos-database-sqlite3 bareos-database-tools bareos-devel bareos-director 
bareos-storage-fifo bareos-tools bareos-filedaemon bareos-storage bareos-storage-tape 
bareos-director-python-plugin bareos-filedaemon-python-plugin bareos-storage-python-plugin "
==> Install only bareos-common ? [Y/n]
==> ----------------------------------
==> N       //choose N to install all packages

After couple of minutes we have installed all needed packages.

=> Continue installing bareos ? [Y/n]
==> [v]iew package contents [c]heck package with namcap
==> ---------------------------------------------------
==>                        //type Y or hit ENTER

loading packages...
resolving dependencies...
warning: cannot resolve "mtx", a dependency of "bareos-storage-tape"
:: The following package cannot be upgraded due to unresolvable dependencies:
bareos-storage-tape

:: Do you want to skip the above package for this upgrade? [y/N] y   // type y as we can skip this package
looking for conflicting packages...

Packages (17) postgresql-9.4.4-2 bareos-bconsole-14.2.5-3 bareos-common-14.2.5-3
bareos-database-common-14.2.5-3 bareos-database-mysql-14.2.5-3
bareos-database-postgresql-14.2.5-3 bareos-database-sqlite3-14.2.5-3
bareos-database-tools-14.2.5-3 bareos-devel-14.2.5-3 bareos-director-14.2.5-3
bareos-director-python-plugin-14.2.5-3 bareos-filedaemon-14.2.5-3
bareos-filedaemon-python-plugin-14.2.5-3 bareos-storage-14.2.5-3
bareos-storage-fifo-14.2.5-3 bareos-storage-python-plugin-14.2.5-3
bareos-tools-14.2.5-3

Total Download Size: 4.99 MiB
Total Installed Size: 27.29 MiB

:: Proceed with installation? [Y/n]

You can also install only packages you need:

$ yaourt -S bareos-bconsole bareos-common bareos-database-common bareos-database-mysql
 bareos-database-tools bareos-director bareos-filedaemon bareos-storage bareos-tools

and install only these ones.

STEP 3 – Make Bareos database

According of what type database you decide to use we need to create database and tables. In our case we use MariaDB database. In STEP 1 we configured database server. If you secured root access by password create the file /root/.my.cnf with credential:

$ sudo nano /root/.my.cnf
[client]
host=localhost
user=root
password=RootPasswordForMysql

We also have to say to Bareos which type of database we want to use. Edit /etc/bareos/bareos-dir.conf

$ sudo nano /etc/bareos/bareos-dir.conf

and change the type of database,

# Generic catalog service
#
Catalog {
Name = MyCatalog
# Uncomment the following lines if you want the dbi driver
# dbdriver = "dbi:postgresql"; dbaddress = 127.0.0.1; dbport =
#dbdriver = "postgresql"
dbdriver = "TH_DATABASE_DRIVER_XXX"
dbname = "bareos"
dbuser = "bareos"
dbpassword = ""
}

to mysql database:

# Generic catalog service
#
Catalog {
Name = MyCatalog
# Uncomment the following lines if you want the dbi driver
# dbdriver = "dbi:postgresql"; dbaddress = 127.0.0.1; dbport =
#dbdriver = "postgresql"
dbdriver = "mysql"
dbname = "bareos"
dbuser = "bareos"
dbpassword = ""
}

Now create database and tables and grant privileges:

$ sudo sh /usr/lib/bareos/scripts/create_bareos_database
$ sudo /usr/lib/bareos/scripts/make_bareos_tables
$ sudo /usr/lib/bareos/scripts/grant_bareos_privileges

STEP 4 – Run Bareos

Now we can fire up each bareos modules and enable them on startup.

Main module:

$ sudo systemctl start bareos-dir
$ sudo systemctl enable bareos-dir

Storage daemon:

$ sudo systemctl start bareos-sd
$ sudo systemctl enable bareos-sd

File daemon (have to run on every backuped server/pc):

$ sudo systemctl start bareos-fd
$ sudo systemctl enable bareos-fd

We can check the status of system using bconsole command:

$ sudo bconsole
Connecting to Director unixmen:9101
1000 OK: unixmen-dir Version: 14.2.5 (27 May 2015)
Enter a period to cancel a command.
*status                        //type status
Status available for:
1: Director
2: Storage
3: Client
4: Scheduler
5: All
Select daemon type for status (1-5): 5        //choose it for all information
unixmen-dir Version: 14.2.5 (27 May 2015) x86_64-unknown-linux-gnu debian
Daemon started 02-Oct-15 21:21. Jobs: run=0, running=0 mode=0
Heap: heap=409,600 smbytes=87,662 max_bytes=89,018 bufs=298 max_bufs=307

Scheduled Jobs:
Level Type Pri Scheduled Name Volume
===================================================================================
Full Backup 10 03-Oct-15 21:00 BackupClient1 *unknown*
====

Running Jobs:
Console connected at 02-Oct-15 21:49
No Jobs running.
====
No Terminated Jobs.
====
Connecting to Storage daemon File at unixmen:9103

unixmen-sd Version: 14.2.5 (27 May 2015) x86_64-unknown-linux-gnu debian
Daemon started 02-Oct-15 21:21. Jobs: run=0, running=0.
Heap: heap=270,336 smbytes=31,510 max_bytes=88,815 bufs=69 max_bufs=71
Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0 bwlimit=0kB/s

Running Jobs:
No Jobs running.
====

Jobs waiting to reserve a drive:
====

Terminated Jobs:
====

Device status:

Device "FileStorage" (/var/lib/bareos/storage) is not open.
==
====

Used Volume status:
====

====

Connecting to Client unixmen-fd at unixmen:9102

unixmen-fd Version: 14.2.5 (27 May 2015) x86_64-unknown-linux-gnu debian
Daemon started 02-Oct-15 21:21. Jobs: run=0 running=0.
Heap: heap=135,168 smbytes=26,875 max_bytes=27,264 bufs=55 max_bufs=58
Sizeof: boffset_t=8 size_t=8 debug=0 trace=0 bwlimit=0kB/s

Running Jobs:
Director connected at: 02-Oct-15 21:50
No Jobs running.
====

Terminated Jobs:
====
*
*exit             //exit bconsole

CONCLUSION

In this article, we successfully installed Bareos backup system and all needed application. Bareos is running and enabled on startup. In next articles, we install application to manage Bareos using either CLI or GUI and also we can learn how-to setup all components and make jobs for backuping one or more servers/PC’s

Reference: