Having an up-to-date backup copy for any user (especially a business) is extremely important since no one is immune from unpleasant events associated with media failure, loss of information, accidental deletion, etc. In such situations, a backup becomes the only way to restore your priceless data, and therefore it can save you a lot of trouble, wasted time, damaged nerves, and wasted money.
We chose the popular Bareos software as our backup system because it:
- is an OpenSource solution;
- actively developing;
- has many useful features;
- can expand its functionality with plugins.
Task Description
For example, let's take three servers: Bareos, BitrixVM, and Windows Server 2012 R2. In our case, they are all within the same network; at the same time, Bareos allows you to perform backups even when the machine is offline.
Bareos - 172.16.10.10 BitrixVM - 172.16.10.11 Windows Server - 172.16.10.12
For a server with Bareos, we will use CentOS 7. The usual installation takes place:
# yum install -y bareos-client bareos-database-tools bareos-filedaemon bareos-database-mysql bareos bareos-bconsole bareos-database-common bareos-storage bareos-director bareos-common
PostgreSQL will be used as the database. Installation is just as easy:
# yum install -y PostgreSQL-server postgresql-contrib
When installing Bareos in /etc/bareos, we have the following list of files and folders (with the exception of the ssl directory, we will move on to it a little later):
/bareos-dir.d
/bareos-sd.d
/ssl
bareos-dir.conf
bareos-fd.conf
bareos-sd.conf
bconsole.conf
.rndpwd
After installation, prepared scripts for working with Bareos will appear in the /usr/lib/bareos/scripts/ directory. Using them, let's pre-configure the database (create the database, tables, and permissions):
su postgres -c /usr/lib/bareos/scripts/create_bareos_database
su postgres -c /usr/lib/bareos/scripts/make_bareos_tables
su postgres -c /usr/lib/bareos/scripts/grant_bareos_privileges
An important nuance: the names of our machines must be resolved; if not, then add the appropriate lines to /etc/hosts:
172.16.10.10 bareos-server
172.16.10.10 bareos-fd
172.16.10.11 bitrixvm
172.16.10.12 win-fd
bareos-server - the server itself, bareos-fd - we will also make a backup of the server itself, i.e. at the same time, it will act as a client, later in the configuration, it will be visible, bitrixvm is a client with BitrixVM, win-fd is a client with Windows Server 2012 R2.
The server part for Bareos (namely, the director) must be configured in the bareos-dir.conf file. The director is responsible for all operations performed.
Main directives:
**Director** — description of the director himself;
**Storage** - the device on which we write backups;
**Catalog** - contains information on completed Jobs, saved files, clients, and statuses;
**Messages** - what messages will be collected and how to deliver them;
**Console** - setting up the console for managing the director;
**Client** — description of the client from which the backups will be taken;
**Pool** - allows you to manage the Volume where data will be written for different types of backup (Full, Incremental, Differential), limit the storage period of the Volume, sizes;
**FileSet** - we determine what data is to be backed up, and additional attributes;
Schedule - schedule;
**Job** - Description of the backup task.
The scheme of interaction between services looks like this (from the official Bareos documentation):
Contents of the bareos-dir.conf file:
Director {
#Required parameter director's name
Name = bareos-server
# Required parameter for request files
QueryFile="/usr/lib/bareos/scripts/query.sql"
# Number of simultaneously executed Jobs
Maximum Concurrent Jobs = 10
# Password (usually 20-40 characters are used, for the test, we will limit ourselves to 9 characters)
Password = "zcx@#$BGj"
# Specifying which notifications to use (the Message directive is described below)
Messages = standard
# TLS encryption. Will be described next.
# TLS enabled
TLS Enable=yes
TLS Require = yes
TLS Verify Peer = yes
#Allowed CNs
TLS Allowed CN="bareos-server"
TLS Allowed CN="bitrixvm"
TLS Allowed CN="win-fd"
# Location of the CA certificate
TLS CA Certificate File = /etc/bareos/ssl/ca-chain.cert.pem
# certificate location
TLS Certificate = /etc/bareos/ssl/bareos-server.cert.pem
# Location of the key to the certificate
TLS Key = /etc/bareos/ssl/bareos-server.nopass.key.pem
TLS DH File = /etc/bareos/ssl/dh1024.pem
}
Storage {
Name=bareos-server-sd
# You can specify both by IP and by name, for TLS to work correctly, it is important to specify by #name
Address = bareos-server
Password = "zcx@#$BGj"
# Specifies a name for the device where the data will be stored. Device options are set in the bareos-sd.conf file
Device=bareos-sd
Media Type = File
port=9103
TLS Enable=yes
TLS Require = yes
TLS CA Certificate File = /etc/bareos/ssl/ca-chain.cert.pem
TLS Certificate = /etc/bareos/ssl/bareos-server.cert.pem
TLS Key = /etc/bareos/ssl/bareos-server.nopass.key.pem
}
Catalog {
#Set all parameters for connecting to the database
Name = bareos-server
dbdriver="postgresql"
dbname="bareos"
dbuser="bareos"
dbpassword=""
}
messages {
# Describes the types of messages that should be sent and logged
Name = Standard
mail = root@localhost = all, !skipped, !audit
console = all, !skipped, !saved, !audit
append = "/var/log/bareos/bareos.log" = all, !skipped, !audit
append = "/var/log/bareos/bareos-audit.log" = audit
}
client {
# Client name for backup
Name=bareos-fd
# Directory name
Catalog = bareos-server
enabled = yes
# Address set by name
Address = bareos-server
Password = "zcx@#$BGj"
port=9102
# TLS parameters will be described later
TLS Enable=yes
TLS Require = yes
TLS CA Certificate File = /etc/bareos/ssl/ca-chain.cert.pem
TLS Certificate = /etc/bareos/ssl/bareos-server.cert.pem
TLS Key = /etc/bareos/ssl/bareos-server.nopass.key.pem
}
Pool {
# Pool name for full backup
Name = bareos-pool -Full
# Automatically adds a label like "bareos-client-Full-" + number #Volume to the backup file
#For example, the final name of Volume after the next backup will look like bareos-client-# Full-0009
Label Format="bareos-client-Full-"
# Pool type. According to the official documentation of BareOS, only the Backup type is currently implemented
Pool Type = Backup
# Volume for a full backup is stored for 3 months
Volume Retention = 3 months
# after which the directory is cleared of obsolete data
AutoPrune = yes
# Volume is overwritten
Recycle = yes
}
Pool {
# Pool name for incremental backup
Name = bareos-pool-incremental
Pool Type = Backup
Recycle = yes
Auto Prune = yes
Volume Retention = 10 days
Label Format="bareos-client-Incremental-"
}
Pool {
# Pool name for differential backup
Name=bareos-pool-Differential
Pool Type = Backup
Recycle = yes
Auto Prune = yes
Volume Retention = 11 days
Label Format="bareos-client-Differential-"
}
FileSet {
# Set a name for a set of files
Name=bareos-fileset
# In Include, we specify which files will be saved. In this case, the /etc folder
include {
File="/etc"
}
}
Schedule {
#Schedule name
Name="MonthlyCycle"
# Perform a full backup once a week
Run = Level = Full mon at 2:00
# During the day 5 incremental backups every hour
Run = Level= Incremental hourly at 13:00
Run = Level = Incremental hourly at 14:00
Run = Level = Incremental hourly at 15:00
Run = Level = Incremental hourly at 16:00
Run = Level = Incremental hourly at 17:00
}
job {
# Name for the task
Name = Job-Full
# Its type. Can be Backup or Restore
Type = Backup
# Backup level. Full, Differential or Incremental
Level = Incremental
# For which client the Job is being executed
Client=bareos-fd
# Set of files
FileSet = bareos-fileset
# Schedule
Schedule = "Monthly Cycle"
# Name of Storage used
Storage=bareos-server-sd
# Alerts
Messages = standard
# Used pool
Pool = bareos-pool-Full
Full Backup Pool = bareos-pool -Full
Differential Backup Pool = bareos-pool-Differential
Incremental Backup Pool = bareos-pool-Incremental
}
job {
Name = Job-Full-restore
Type = Restore
Client=bareos-fd
FileSet="bareos-fileset"
Storage=bareos-server-sd
Pool = bareos-pool-Full
Messages = standard
# Specify the path where all the files will go when restoring
Where=/tmp
}