BareOS,一个完整的开源备份方案
介绍
BareOS 是一个基于Bacula这个开源备份软件进行frok和二次开发的企业级备份软件。Bareos的团队位于德国,主要开发人员是从SUSE出来创业的老头子,他们首先通过的兼容性认证的也是SUSE的。BareOS相对于Bacula而言,功能强化了管理和对插件的支持,并提供了官方的web管理控制台。需要注意的是,BareOS的repo是区分商业版和社区版的,商业版使用.com的域名,社区版使用.org域名。
有关于Bacula的部署和使用,可以看这里
部署
主机名 | IP地址 | 任务角色 |
---|---|---|
BareOS | 192.168.10.250 | 备份服务器 |
Client | 192.168.10.101 | 备份客户端 |
安装软件
# 安装备份软件
wget https://download.bareos.org/current/EL_9/add_bareos_repositories.sh
sh ./add_bareos_repositories.sh
dnf makecache
dnf -y install bareos
# 创建相关目录
mkdir -p /bacula/backup /bacula/restore
chown -R bacula:bacula /bacula
chmod -R 700 /bacula
# 开启防火墙
firewall-cmd --permanent --add-service=bacula
firewall-cmd --reload
准备数据库
# 安装
dnf -y install postgresql-server
postgresql-setup --initdb
systemctl enable --now postgresql
# 创建数据库相关表
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
# 访问测试
[root@bareos ~]# su - postgres
[postgres@bareos ~]$ psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+-----------+-------------+-------------+-----------------------
bareos | postgres | SQL_ASCII | C | C |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
# 拉起服务
systemctl enable --now bareos-dir
systemctl enable --now bareos-sd
systemctl enable --now bareos-fd
安装WEB-UI
# 默认使用httpd
dnf install -y bareos-webui
systemctl enable --now httpd
firewall-cmd --permanent --add-service={http,https}
firewall-cmd --reload
# 配置门户密码(默认使用admin:admin)
cp /etc/bareos/bareos-dir.d/console/admin.conf.example /etc/bareos/bareos-dir.d/console/admin.conf
systemctl restart bareos-dir
访问路径为:http://主机地址/bareos-webui/
配置
目录结构
[root@bareos ~]# tree /etc/bareos
/etc/bareos
├── bareos-dir.d
│ ├── catalog
│ │ └── MyCatalog.conf
│ ├── client
│ │ └── bareos-fd.conf
│ ├── console
│ │ ├── admin.conf
│ │ ├── admin.conf.example
│ │ └── bareos-mon.conf
│ ├── counter
│ ├── director
│ │ └── bareos-dir.conf
│ ├── fileset
│ │ ├── Catalog.conf
│ │ ├── LinuxAll.conf
│ │ ├── SelfTest.conf
│ │ └── Windows All Drives.conf
│ ├── job
│ │ ├── backup-bareos-fd.conf
│ │ ├── BackupCatalog.conf
│ │ └── RestoreFiles.conf
│ ├── jobdefs
│ │ └── DefaultJob.conf
│ ├── messages
│ │ ├── Daemon.conf
│ │ └── Standard.conf
│ ├── pool
│ │ ├── Differential.conf
│ │ ├── Full.conf
│ │ ├── Incremental.conf
│ │ └── Scratch.conf
│ ├── profile
│ │ ├── operator.conf
│ │ ├── webui-admin.conf
│ │ ├── webui-limited.conf.example
│ │ └── webui-readonly.conf
│ ├── schedule
│ │ ├── WeeklyCycleAfterBackup.conf
│ │ └── WeeklyCycle.conf
│ ├── storage
│ │ └── File.conf
│ └── user
├── bareos-dir-export
│ └── client
├── bareos-fd.d
│ ├── client
│ │ └── myself.conf
│ ├── director
│ │ ├── bareos-dir.conf
│ │ └── bareos-mon.conf
│ └── messages
│ └── Standard.conf
├── bareos-sd.d
│ ├── autochanger
│ ├── device
│ │ └── FileStorage.conf
│ ├── director
│ │ ├── bareos-dir.conf
│ │ └── bareos-mon.conf
│ ├── messages
│ │ └── Standard.conf
│ ├── ndmp
│ └── storage
│ └── bareos-sd.conf
├── bconsole.conf
└── tray-monitor.d
├── client
│ └── FileDaemon-local.conf
├── director
│ └── Director-local.conf
└── storage
└── StorageDaemon-local.conf
32 directories, 40 files
管理终端(bconsole):
bconsole:全功能CLI管理终端。
WebUI:只能用于备份和恢复,同时包含基于Web的CLI界面。管理服务(bareos-dir):
运行在bareos管理机上,包含全部管理功能、CLI管理服务、WebUI后台支持、目录(catalog)数据库支持等。存储服务(bareos-sd):
运行在bareos管理机上,支持不同的物理存储媒体(如硬盘存储系统、磁带存储系统等),管理数据的读取和存储。文件服务(bareos-fd):
运行在客户机上,管理本地文件的备份和恢复。储存媒体:
物理存储媒体(如硬盘存储系统、磁带存储系统等)
连接数据库
[root@bareos ~]# cd /etc/bareos/bareos-dir.d/
[root@bareos bareos-dir.d]# ls
catalog console director job messages profile storage
client counter fileset jobdefs pool schedule user
# 使用本机root账号的登陆数据库,所以默认不设密码
[root@bareos bareos-dir.d]# cat catalog/MyCatalog.conf
Catalog {
Name = MyCatalog
dbname = "bareos"
dbuser = "bareos"
dbpassword = ""
}
配置客户端
[root@bareos client]# pwd
/etc/bareos/bareos-dir.d/client
# 本地信息
[root@bareos client]# cat bareos-fd.conf
Client {
Name = bareos-fd
Description = "Client resource of the Director itself."
Address = localhost
Password = "9lvO7RcbxLdb4iqY4CSguiU80DtR2f2jS595gslNXx28" # password for FileDaemon
}
配置存储
# 进入存储配置目录
[root@bareos bareos]# cd bareos-sd.d/
[root@bareos bareos-sd.d]# ls
autochanger device director messages ndmp storage
# 本地备份配置文件
[root@bareos bareos-sd.d]# cat device/FileStorage.conf
Device {
Name = FileStorage
Media Type = File
Archive Device = /var/lib/bareos/storage
LabelMedia = yes; # lets Bareos label unlabeled media
Random Access = yes;
AutomaticMount = yes; # when device opened, read it
RemovableMedia = no;
AlwaysOpen = no;
Description = "File device. A connecting Director must have the same Name and MediaType."
}
重启服务
# 测试配置信息是否正确
su bareos -s /bin/sh -c "/usr/sbin/bareos-dir -t"
su bareos -s /bin/sh -c "/usr/sbin/bareos-sd -t"
bareos-fd -t
bconsole -t
# 重启服务
systemctl restart bareos-dir
systemctl restart bareos-sd
systemctl restart bareos-fd
客户端
安装
# 安装备份软件
wget https://download.bareos.org/current/EL_9/add_bareos_repositories.sh
sh ./add_bareos_repositories.sh
dnf makecache
dnf -y install bareos-client
systemctl enable --now bacula-fd
# 开启防火墙
firewall-cmd --permanent --add-service=bacula-client
firewall-cmd --reload
# 返回服务器上创建客户端信息
[root@bareos ~]# bconsole
*configure add client name=client-fd address=client.contoso.com password=testPw0rd
Exported resource file "/etc/bareos/bareos-dir-export/client/client-fd/bareos-fd.d/director/bareos-dir.conf":
Director {
Name = "bareos-dir"
Password = "[md5]6180cedccd8308ed85ca676e2be5aabf"
}
Created resource config file "/etc/bareos/bareos-dir.d/client/client-fd.conf":
Client {
Name = "client-fd"
Address = "client.contoso.com"
Password = "testPw0rd"
}
# 可以得到两个文件
# /etc/bareos/bareos-dir-export/client/client-fd/bareos-fd.d/director/bareos-dir.conf
# /etc/bareos/bareos-dir.d/client/client-fd.conf
# 将上述文件复制到客户端对应文件夹
scp /etc/bareos/bareos-dir-export/client/client-fd/bareos-fd.d/director/bareos-dir.conf root@client.contoso.com:/etc/bareos/bareos-fd.d/director/
scp /etc/bareos/bareos-dir.d/client/client-fd.conf root@client.contoso.com:/etc/bareos/bareos-dir.d/client/
# 让服务器重新读取配置文件
[root@bareos ~]# bconsole
Connecting to Director localhost:9101
Encryption: TLS_CHACHA20_POLY1305_SHA256 TLSv1.3
1000 OK: bareos-dir Version: 22.1.2~pre4.c37b33136 (06 November 2023)
Bareos community build (UNSUPPORTED).
Get professional support from https://www.bareos.com
You are connected using the default console
Enter a period (.) to cancel a command.
*reload
reloaded
使用
参考
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.