Bareos 25.1 配置参数详解

Bareos 25.1 配置参数详解:/etc/bareos 三目录(bareos-dir.d/bareos-sd.d/bareos-fd.d)12 类资源逐类拆解,参数查看(show/--xc 导出)、reload 热生效与语法错误拒载实测,安装默认配置逐文件解析与单机磁盘备份生产模板,全部取自 Ubuntu 22.04 实测环境。

BareosBareos数据备份2026/10/22

Bareos 25.1 配置参数详解

目标:系统拆解 Bareos 的配置体系——/etc/bareos/bareos-dir.d/、bareos-sd.d/、bareos-fd.d/ 三个配置目录下全部资源类型的参数含义、默认值与生效机制,并给出一套可直接落地的单机磁盘备份生产模板。全部配置文件内容与命令回显取自 Ubuntu 22.04.5 LTS + Bareos 25.1.2~pre49.d5742f640 实测环境(安装过程见《Ubuntu 22.04 安装 Bareos 25.1 指南》)。

一、环境信息

  • 操作系统:Ubuntu 22.04.5 LTS(x86_64,主机名 bareos-server);
  • Bareos 版本:25.1.2~pre49.d5742f640(社区 current 通道,构建日期 2026-10-16);
  • 配置来源:apt-get install bareos bareos-database-postgresql bareos-webui 安装后的默认配置(未做手写模板),共 35 个配置文件(目录 12 类资源 + SD 侧 4 类 + FD 侧 3 类 + bconsole.conf);
  • 目录数据库:PostgreSQL 14.24;
  • 实测时间:2026-10-21 ~ 2026-10-22。

二、前置条件

三、参数查看与修改方式

3.1 配置目录结构

Bareos 的配置按「守护进程 × 资源类型」两级目录组织,安装后即有如下骨架(实测 ls 整理):

/etc/bareos/
├── bconsole.conf                      # 控制台:连哪个 Director、用什么口令
├── bareos-dir.d/                      # Director 配置(策略层,12 类资源)
│   ├── catalog/MyCatalog.conf         # 目录数据库连接
│   ├── client/bareos-fd.conf          # 被备份客户端清单
│   ├── console/                       # 命名控制台账号(bareos-mon、admin 示例)
│   ├── director/bareos-dir.conf       # Director 自身全局参数
│   ├── fileset/                       # 备什么(SelfTest/Catalog/LinuxAll)
│   ├── job/                           # 作业定义(备份/还原)
│   ├── jobdefs/DefaultJob.conf        # 作业默认值模板
│   ├── messages/                      # 消息投递(Daemon/Standard)
│   ├── pool/                          # 介质池(Full/Differential/Incremental/Scratch)
│   ├── profile/                       # 控制台权限画像(operator/webui-admin)
│   ├── schedule/                      # 排程(WeeklyCycle 等)
│   └── storage/File.conf              # 指向哪个存储守护进程
├── bareos-sd.d/                       # Storage Daemon 配置(存储层,4 类资源)
│   ├── device/FileStorage.conf        # 存储设备(写到哪个目录/磁带机)
│   ├── director/                      # 允许哪些 Director 连入
│   ├── messages/Standard.conf         # 消息回送 Director
│   └── storage/bareos-sd.conf         # SD 自身全局参数
└── bareos-fd.d/                       # File Daemon 配置(客户端层,3 类资源)
    ├── client/myself.conf             # 本机 FD 身份
    ├── director/                      # 允许哪个 Director 连入(口令校验)
    └── messages/Standard.conf         # 消息回送 Director

各目录职责与安装过程见安装篇 7.1 节;本篇按资源类型逐类展开参数。

3.2 查看当前生效配置

方式一:bconsole 的 show 系列——查看 Director 解析后的内存态资源(含默认值展开),以 show filesets 为例:

printf "show filesets\nquit\n" | bconsole | tail -40

实测回显(节选,注意 Director 已把简写展开为实际生效值):

FileSet {
  Name = "Catalog"
  Description = "Backup the catalog dump and Bareos configuration files."
  Include {
    Options {
      Signature = "XXH128"
      HardLinks = No
      AclSupport = Yes
      XattrSupport = Yes
    }
    File = "/var/lib/bareos/bareos.sql"
    File = "/etc/bareos"
  }
}

配置文件里只写了 Signature = XXH128,而 HardLinks/AclSupport/XattrSupport 是解析后的默认值——排查「我明明没配为什么生效了」类问题时以 show 输出为准。其余常用形式:show jobs、show pools、show clients、show schedules、show storages、show filesets,按资源类型逐个查看。

方式二:bconsole --xc 导出运行配置(脱敏为 MD5 指纹):

bconsole --xc

实测回显:

Director {
  Name = "bareos-dir"
  Description = "Bareos Console credentials for local Director"
  Address = "localhost"
  Password = "[md5]a082a1a46efa9b1c9ab48cc44f8d736e"
}

💡 说明:--xc 导出的是 bconsole 自身的配置(password 自动做 MD5 掩码展示),适合核对控制台侧凭据;Director 侧全部资源以 show 系列为准。

3.3 修改与生效机制:reload 热加载

修改任一 .conf 后无需重启服务,在 bconsole 执行 reload 即可让 Director 重新读取配置:

printf "reload\nquit\n" | bconsole | tail -3

实测回显:

reload
reloaded
You have messages.

配置有语法错误时 reload 会被拒绝(实测:临时加入一个含不存在指令的 Pool 资源后执行 reload):

reload
failed to reload
You have messages.

删除错误文件后再次 reload 恢复 reloaded。因此标准修改流程是「改文件 → reload → 看回显是 reloaded 还是 failed to reload」;failed to reload 时 Director 继续使用旧配置运行,服务不中断。改动前想先做语法校验可用:

runuser -u bareos -- bareos-dir -t      # exit 0 即语法正确(需以 bareos 系统用户执行,原因见安装篇 FAQ 8.3)

四、参数总览

Director 侧 12 类资源与 SD/FD 侧资源的分工矩阵(全部为安装默认存在的资源类型):

资源类型所在目录回答的问题默认文件
Directorbareos-dir.d/director/调度器自身并发数、口令、审计bareos-dir.conf
Catalogbareos-dir.d/catalog/目录库连哪个库MyCatalog.conf
Clientbareos-dir.d/client/备份哪些机器bareos-fd.conf
Job / JobDefsbareos-dir.d/job/、jobdefs/何时备份谁、怎么备backup-bareos-fd.conf 等 3 个
FileSetbareos-dir.d/fileset/备什么文件、排除什么SelfTest/Catalog/LinuxAll.conf
Schedulebareos-dir.d/schedule/什么时间什么级别WeeklyCycle.conf 等 2 个
Poolbareos-dir.d/pool/备份写到哪类介质、保留多久Full/Differential/Incremental/Scratch.conf
Storagebareos-dir.d/storage/交给哪个 SD 写File.conf
Messagesbareos-dir.d/messages/作业/守护消息发给谁Daemon/Standard.conf
Consolebareos-dir.d/console/哪些命名控制台账号可连bareos-mon.conf(admin 为示例)
Profilebareos-dir.d/profile/控制台账号能做什么operator/webui-admin.conf
Storage(SD 侧)bareos-sd.d/storage/SD 自身身份bareos-sd.conf
Device(SD 侧)bareos-sd.d/device/介质写到哪、怎么 labelFileStorage.conf
Director(SD/FD 侧)bareos-sd.d/director/、bareos-fd.d/director/准许哪个 Director 连入bareos-dir.conf、bareos-mon.conf
Client(FD 侧)bareos-fd.d/client/本机 FD 名字myself.conf
Messages(SD/FD 侧)bareos-sd.d/messages/、bareos-fd.d/messages/消息回送Standard.conf

💡 技术拓展:备份系统的「保留策略」常见两种实现对比——

策略模型原理适用场景
介质保留(Bareos/Bacula 式 Volume Retention)以 Volume(介质卷)为单位设保留期,到期后 AutoPrune 清理过期作业、Recycle 复用整卷磁带/大容量磁盘池,整卷生命周期管理
快照/GFS 轮转按日/周/月直接删旧快照目录rsnapshot 类硬链接快照工具

Bareos 采用 Volume Retention + Pool 分层的介质保留模型,本文方案即采用该模型(Pool 参数见 5.7 节)。

五、核心参数分类详解

以下每段先给实测配置文件原文,再逐项解释关键参数。

5.1 Director 资源(bareos-dir.d/director/bareos-dir.conf)

Director {                            # define myself
  Name = bareos-dir
  QueryFile = "/usr/lib/bareos/scripts/query.sql"
  Maximum Concurrent Jobs = 10
  Password = "SMZ8q69TpxKknBGjE/VNTHbVJGhdyXqv9PEBsVJMsUh7"         # Console password
  Messages = Daemon
  Auditing = yes

  # Set to the number of purchased subscription units
  #
  # Subscriptions = 100


  # Enable the Heartbeat if you experience connection losses
  # (eg. because of your router or firewall configuration).
  # Additionally the Heartbeat can be enabled in bareos-sd and bareos-fd.
  #
  # Heartbeat Interval = 1 min

  # remove comment from "Plugin Directory" to load plugins from specified directory.
  # if "Plugin Names" is defined, only the specified plugins will be loaded,
  # otherwise all director plugins (*-dir.so) from the "Plugin Directory".
  #
  # Plugin Directory = "/usr/lib/bareos/plugins"
  # Plugin Names = ""
}

逐项说明:

  • Name:Director 实例名,bconsole、SD、FD 侧配置里引用的「对方名字」必须与它一致——这是三端配对的主键;
  • QueryFile:bconsole 查询菜单(show/restore 向导的 SQL 查询集)所需脚本路径,保持默认勿动;
  • Maximum Concurrent Jobs = 10:Director 可并行调度的作业上限,默认 10;多客户端并发备份场景按 SD 设备数与磁盘 IO 能力上调;
  • Password:默认 Console(bconsole)的口令,与 /etc/bareos/bconsole.conf 中的 Password 成对,成对替换才有效;
  • Messages = Daemon:Director 自身守护消息使用名为 Daemon 的 Messages 资源投递;
  • Auditing = yes:记录控制台操作审计到 audit 日志(配合 Messages 的 !audit 过滤);
  • Heartbeat Interval(注释态):经防火墙/NAT 的部署若出现连接中断,三端(dir/sd/fd)同时开启心跳保活;
  • Plugin Directory/Plugin Names(注释态):加载 Director 侧 Python 插件目录,Plugin Names 未设时加载目录内全部 *-dir.so。

5.2 Catalog 资源(bareos-dir.d/catalog/MyCatalog.conf)

Catalog {
  Name = MyCatalog
  dbname = "bareos"
  dbuser = "bareos"
  dbpassword = ""
}
  • dbname/dbuser:dbconfig-common 安装时自动创建的库名与用户名(安装实录见安装篇 4.3 节阶段二);
  • dbpassword 为空:默认走 Unix socket + peer 认证(操作系统用户 bareos 连数据库用户 bareos),因此排障命令都要 runuser -u bareos -- 执行;
  • 如把目录库放到远程数据库主机,此处补 dbaddress/dbport 并在库端放开口令认证。

5.3 Client 资源(bareos-dir.d/client/bareos-fd.conf)

Client {
  Name = bareos-fd
  Description = "Client resource of the Director itself."
  Address = localhost
  Password = "5WcmDTezgFar8V5KEFZGw29I5W/FMf+bg2iNdf1ny9kQ"          # password for FileDaemon
}
  • 每台被备份主机一个 Client 资源;Name 对端即 FD 侧 bareos-fd.d/client/myself.conf 定义的 FD 身份(本机默认 bareos-fd 对应 FD 内部名 bareos-server-fd,作业记录中 client 列显示为 bareos-fd);
  • Address:FD 可达地址(IP 或 FQDN);新增客户端时写 FQDN 或固定 IP;
  • Password:与目标 FD 侧 bareos-fd.d/director/bareos-dir.conf 的 Password 成对——这是 Director↔FD 的预共享口令(TLS-PSK 加密通道的基础),新增客户端时的标准动作是「两端同密码、同名字」。

5.4 Job 与 JobDefs 资源

JobDefs 默认值模板(bareos-dir.d/jobdefs/DefaultJob.conf):

JobDefs {
  Name = "DefaultJob"
  Type = Backup
  Level = Incremental
  Client = bareos-fd
  FileSet = "SelfTest"                     # selftest fileset
  Schedule = "WeeklyCycle"
  Storage = File
  Messages = Standard
  Pool = Incremental
  Priority = 10
  Write Bootstrap = "/var/lib/bareos/%c.bsr"
  Full Backup Pool = Full                  # write Full Backups into "Full" Pool
  Differential Backup Pool = Differential  # write Diff Backups into "Differential" Pool
  Incremental Backup Pool = Incremental    # write Incr Backups into "Incremental" Pool
}
  • JobDefs 是「作业参数包」:多个 Job 引用同一 JobDefs 可避免重复配置;Job 内显式写的指令覆盖 JobDefs 值;
  • Level = Incremental:默认增量;首次运行无历史全量时 Bareos 自动升级为全量;
  • Write Bootstrap = "/var/lib/bareos/%c.bsr":每个作业的引导文件(%c 展开为客户端名),灾难恢复时指定从哪里读起;
  • 三个 * Backup Pool 指令实现「按备份级别分流介质池」——全量进 Full 池、差异进 Differential 池、增量进 Incremental 池,保留期各自独立(见 5.7 节)。

备份作业(bareos-dir.d/job/backup-bareos-fd.conf):

Job {
  Name = "backup-bareos-fd"
  JobDefs = "DefaultJob"
  Client = "bareos-fd"
}

仅三项:引用默认模板并指明客户端——新增一台客户端的备份作业就是复制这三行改 Client。

目录库自备份作业(bareos-dir.d/job/BackupCatalog.conf,节选):

Job {
  Name = "BackupCatalog"
  Description = "Backup the catalog database (after the nightly save)"
  JobDefs = "DefaultJob"
  Level = Full
  FileSet="Catalog"
  Schedule = "WeeklyCycleAfterBackup"
  RunBeforeJob = "/usr/lib/bareos/scripts/make_catalog_backup MyCatalog"
  RunAfterJob  = "/usr/lib/bareos/scripts/delete_catalog_backup MyCatalog"
  Write Bootstrap = "|/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" root"
  Priority = 11                   # run after main backup
}
  • RunBeforeJob 先导出目录库 ASCII 快照(make_catalog_backup),RunAfterJob 删除快照——目录库自身也要被备份;
  • Priority = 11:默认作业是 10,目录库备份排队在常规备份之后跑,避免争抢窗口。

还原作业模板(bareos-dir.d/job/RestoreFiles.conf):

Job {
  Name = "RestoreFiles"
  Description = "Standard Restore template. Only one such job is needed for all standard Jobs/Clients/Storage ..."
  Type = Restore
  Client = bareos-fd
  FileSet = "LinuxAll"
  Storage = File
  Pool = Incremental
  Messages = Standard
  Where = /tmp/bareos-restores
  Maximum Concurrent Jobs = 10
}
  • Type = Restore:还原作业不排程,由 restore 命令驱动;全站一个模板即可;
  • Where = /tmp/bareos-restores:还原数据落盘的重定向根路径;bconsole 的 restore ... where= 参数可运行时覆盖该值(安装篇 4.6 节闭环实测)。

5.5 FileSet 资源

SelfTest(安装即用的自检文件集):

FileSet {
  Name = "SelfTest"
  Description = "fileset just to backup some files for selftest"
  Include {
    Options {
      Signature = XXH128 # calculate checksum per file
    }
    File = "/usr/sbin"
  }
}
  • File = "/usr/sbin":备份目标;Options.Signature = XXH128 为每文件计算 128 位 XXH 校验和(校验与去重友好);选项块支持 Compression(如 GZIP/LZ4/ZSTD)、One FS(是否跨文件系统)等。

LinuxAll(整机文件集,节选保留注释语义):

FileSet {
  Name = "LinuxAll"
  Include {
    Options {
      Signature = XXH128
      One FS = No
      FS Type = btrfs
      FS Type = ext2
      FS Type = ext3
      FS Type = ext4
      FS Type = reiserfs
      FS Type = jfs
      FS Type = vfat     # UEFI
      FS Type = xfs
      FS Type = zfs
    }
    File = /
  }
  Exclude {
    File = /var/lib/bareos
    File = /var/lib/bareos/storage
    File = /proc
    File = /dev
    File = /sys
    File = /tmp
    File = /var/tmp
  }
}
  • FS Type 白名单:只抓指定类型的文件系统( procfs/sysfs 等伪文件系统天然被排除);
  • One FS = No:允许跨文件系统边界(配合 FS Type 白名单才安全);
  • Exclude 里的 /var/lib/bareos/storage 是关键项:备份存储目录绝不能进备份集,否则递归自吞。

Catalog:备份 /var/lib/bareos/bareos.sql(目录库导出快照,由 BackupCatalog 作业的 RunBeforeJob 生成)与 /etc/bareos(配置目录)。

5.6 Schedule 资源(bareos-dir.d/schedule/)

Schedule {
  Name = "WeeklyCycle"
  Run = Full 1st sat at 21:00
  Run = Differential 2nd-5th sat at 21:00
  Run = Incremental mon-fri at 21:00
}

Schedule {
  Name = "WeeklyCycleAfterBackup"
  Description = "This schedule does the catalog. It starts after the WeeklyCycle."
  Run = Full mon-fri at 21:10
}
  • Run 行语法:<级别> <日期修饰> at <时刻>;日期修饰支持 1st sat(第一个周六)、2nd-5th sat(第二到第五个周六)、mon-fri(工作日)、daily、hourly 等;
  • WeeklyCycle 的语义:每月第一个周六全量、其余周六差异、工作日增量——GFS 轮转的池化实现;
  • WeeklyCycleAfterBackup 每天 21:10 跑 Full 级别的目录库备份(跟在 21:00 常规备份后)。

5.7 Pool 资源(bareos-dir.d/pool/)

三个备份池 + 一个暂存池:

Pool {
  Name = Full
  Pool Type = Backup
  Recycle = yes                       # Bareos can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 365 days         # How long should the Full Backups be kept?
  Maximum Volume Bytes = 50G          # Limit Volume size to something reasonable
  Maximum Volumes = 100               # Limit number of Volumes in Pool
  Label Format = "Full-"              # Volumes will be labeled "Full-<volume-id>"
}

Pool {
  Name = Incremental
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 30 days
  Maximum Volume Bytes = 1G
  Maximum Volumes = 100
  Label Format = "Incremental-"
}

Pool {
  Name = Differential
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 90 days
  Maximum Volume Bytes = 10G
  Maximum Volumes = 100
  Label Format = "Differential-"
}

Pool {
  Name = Scratch
  Pool Type = Scratch
  Recycle Pool = Scratch
}

逐项说明:

  • Pool Type = Backup:常规备份池;Scratch 池是「空卷暂存区」,被回收的卷回到 Scratch,可被其他池按需取用(Recycle Pool = Scratch);
  • Volume Retention:卷内数据保留期——Full 365 天 / Differential 90 天 / Incremental 30 天,构成 GFS 保留梯度;到期后 AutoPrune = yes 自动清理过期作业记录、Recycle = yes 允许整卷复用;
  • Maximum Volume Bytes:单卷上限(50G/10G/1G),控制单文件体积便于归档与去重文件系统分块;
  • Maximum Volumes = 100:池内卷数上限,防磁盘被写爆;
  • Label Format:自动打标前缀,实际卷名如 Full-0001(安装篇 4.6 节首次备份实测产生 Full-0001)。

5.8 Storage 资源(Director 侧)与 SD 侧配置

Director 侧(bareos-dir.d/storage/File.conf)——告诉 Director「有一个叫 File 的存储端」:

Storage {
  Name = File
  Address = bareos-server                # N.B. Use a fully qualified name here (do not use "localhost" here).
  Password = "ghDnzpoxwpdG4c5l96WeY2ufQEsPCNM3QstDgh4KkHbv"
  Device = FileStorage
  Media Type = File
  Maximum Concurrent Jobs = 10
}
  • Address:SD 的网络地址,官方注释明确要求写 FQDN 而非 localhost——因为 FD 也可能按此地址直连 SD 拉流;
  • Password:与 SD 侧 director 资源成对;
  • Device/Media Type:必须与 SD 侧 Device 资源的 Name 和 Media Type 双一致,Director 靠这对值把作业路由到正确设备。

SD 侧身份与设备(bareos-sd.d/storage/bareos-sd.conf、bareos-sd.d/device/FileStorage.conf):

Storage {
  Name = bareos-sd
  # Plugin Directory = "/usr/lib/bareos/plugins"
  # Plugin Names = ""
}

Device {
  Name = FileStorage
  Media Type = File
  Archive Device = /var/lib/bareos/storage
  Label Media = yes                  # lets Bareos label unlabeled media
  Random Access = yes
  Automatic Mount = yes              # when device opened, read it
  Removable Media = no
  Always Open = no
  Description = "File device. A connecting Director must have the same Name and MediaType."
  Count = 10
}
  • Archive Device:备份文件实际落盘目录,改到这里即可把存储迁到大数据盘;
  • Label Media = yes:遇到未打标的空白介质自动创建卷标(配合 Pool 的 Label Format 生成 Full-0001 这样的卷名);
  • Always Open = no:文件设备按需开闭(磁带设备则设 yes 保持独占挂载);
  • Count = 10:从该设备定义自动展开 10 个并发设备实例(FileStorage-1 ~ FileStorage-10),配合 Director 侧 Maximum Concurrent Jobs 实现并行写。

SD 侧 Director 资源(bareos-sd.d/director/bareos-dir.conf)——准入口令:

Director {
  Name = bareos-dir
  Password = "ghDnzpoxwpdG4c5l96WeY2ufQEsPCNM3QstDgh4KkHbv"
  Description = "Director, who is permitted to contact this storage daemon."
}

与 Director 侧 Storage 资源的 Password 成对(同为 ghDn...),Name 也必须与 Director 资源同名。

5.9 Messages 资源

Director 侧两套投递策略:

Messages {
  Name = Daemon
  Description = "Message delivery for daemon messages (no job)."
  mailcommand = "/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos daemon message\" %r"
  mail = root = 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
}

Messages {
  Name = Standard
  Description = "Reasonable message delivery -- send most everything to email address and to the console."
  operatorcommand = "/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos: Intervention needed for %j\" %r"
  mailcommand = "/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \<%r\>\" -s \"Bareos: %t %e of %c %l\" %r"
  operator = root = mount
  mail = root = all, !skipped, !saved, !audit
  console = all, !skipped, !saved, !audit
  append = "/var/log/bareos/bareos.log" = all, !skipped, !saved, !audit
  catalog = all, !skipped, !saved, !audit
}
  • mail/mailcommand:作业/守护消息按级别过滤后经 bsmtp 发邮件给 root(%r 收件人、%j 作业号、%t 类型、%e 退出码、%c 客户端、%l 级别等占位符);!skipped/!audit 为排除级别;
  • console =:同级别消息回显到 bconsole(所以命令执行后常见 You have messages.);
  • append =:落到日志文件;Daemon 资源单独把 audit 级别写进 bareos-audit.log;
  • catalog =:消息同时存入目录数据库(bconsole messages 命令读取的就是它);
  • operator = root = mount:需要人工干预(如换磁带,mount 事件)时通知操作员。

SD/FD 侧只保留最简回送(bareos-sd.d/messages/Standard.conf、bareos-fd.d/messages/Standard.conf):

Messages {
  Name = Standard
  Director = bareos-dir = all
  Description = "Send all messages to the Director."
}

Director = bareos-dir = all:SD/FD 自身不存日志,全部消息回送给 Director 汇总投递。

5.10 Console 与 Profile 资源

命名控制台(bareos-dir.d/console/bareos-mon.conf)——受限监控账号:

Console {
  Name = bareos-mon
  Description = "Restricted console used by tray-monitor to get the status of the director."
  Password = "v4bUCqE0wYEXQEvqhoNNlYMKS5PtFbJxibBvpBwwAVdW"
  CommandACL = status, .status
  JobACL = *all*
}
  • 命名 Console = 「账号 + 权限边界」:CommandACL 白名单限制可执行命令(本例只许 status);JobACL/ClientACL/PoolACL 等限定资源可见范围;
  • WebUI 管理账号 admin 即命名 Console + Profile 组合(admin.conf.example 自带 TLS Enable = No,语义与排查见安装篇 4.6 与 FAQ 8.5)。

权限画像(bareos-dir.d/profile/webui-admin.conf,节选):

Profile {
  Name = "webui-admin"
  CommandACL = !.bvfs_clear_cache, !.exit, !.sql, !configure, !create, !delete, !purge, !prune, !sqlquery, !umount, !unmount, *all*
  Job ACL = *all*
  Schedule ACL = *all*
  Catalog ACL = *all*
  Pool ACL = *all*
  Storage ACL = *all*
  Client ACL = *all*
  FileSet ACL = *all*
  Where ACL = *all*
  Plugin Options ACL = *all*
}
  • *all* 表示该类资源全放开,!命令 表示从通配里再排除——webui-admin 组合的含义是「除 SQL 直查、配置变更、删除清理类命令外全部放开」;
  • Profile 与 Console 分离的设计允许多个账号共享同一权限画像(如 operator 画像给运维组轮换账号用)。

5.11 FD 侧配置(bareos-fd.d/)

Client {                                    # bareos-fd.d/client/myself.conf
  Name = bareos-server-fd
}

Director {                                  # bareos-fd.d/director/bareos-dir.conf
  Name = bareos-dir
  Password = "5WcmDTezgFar8V5KEFZGw29I5W/FMf+bg2iNdf1ny9kQ"
  Description = "Allow the configured Director to access this file daemon."
}

Director {                                  # bareos-fd.d/director/bareos-mon.conf
  Name = bareos-mon
  Password = "bRYLTRP4BW9hOeooWmpB+n1ggbk+InjPPwzY9Qe0CbFo"
  Monitor = yes
}
  • FD 侧 Client 资源定义本机 FD 身份名;Director 侧同名 Client 资源的 Address 指向本机;
  • FD 侧 Director 资源是准入白名单:Name + Password 与 Director 侧 Client 资源成对校验,Monitor = yes 的是只读监控通道(tray-monitor 用);
  • 新增客户端 = 在客户端装 bareos-filedaemon 包 → 在其 bareos-fd.d/director/ 写 Director 准入(或改默认口令)→ 在 Director 侧 bareos-dir.d/client/ 增加同名同密码的 Client 资源 → reload。

六、生产配置模板

适用场景:单台备份服务器承载中小规模环境——8GB 内存、500GB 以上专用数据盘、10 台以内 Linux 客户端、磁盘介质、GFS 周轮转(月全量/周差异/日增量)。以下模板给出与「安装默认值」的差异项与理由,其余保持安装默认即可。

1. Director 并发与心跳(bareos-dir.d/director/bareos-dir.conf 修改):

Director {
  Name = bareos-dir
  QueryFile = "/usr/lib/bareos/scripts/query.sql"
  Maximum Concurrent Jobs = 20
  Password = "SMZ8q69TpxKknBGjE/VNTHbVJGhdyXqv9PEBsVJMsUh7"
  Messages = Daemon
  Auditing = yes
  Heartbeat Interval = 1 min
}
  • Maximum Concurrent Jobs 10→20:10 台客户端各自 1 个作业 + 1 个目录库备份,并发峰值约 11,留 50% 余量;
  • Heartbeat Interval = 1 min:跨防火墙/NAT 部署防连接静默中断(默认关闭)。

2. 池保留梯度(bareos-dir.d/pool/*.conf 修改,8GB 内存/500GB 数据盘按容量反推):

Pool {
  Name = Full
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 180 days
  Maximum Volume Bytes = 100G
  Maximum Volumes = 6
  Label Format = "Full-"
}

Pool {
  Name = Incremental
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 30 days
  Maximum Volume Bytes = 10G
  Maximum Volumes = 10
  Label Format = "Incremental-"
}

Pool {
  Name = Differential
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 60 days
  Maximum Volume Bytes = 20G
  Maximum Volumes = 5
  Label Format = "Differential-"
}
  • 保留梯度压缩为 180/60/30 天:500GB 盘按「每月全量 50GB 级、卷上限 100G、6 卷全量池」规划,全量池占用上限 600G 超盘前必被 AutoPrune+Recycle 回收最旧卷,容量模型自洽;
  • Maximum Volumes 直接卡死池容量上限,是磁盘备份防写爆的第一道闸。

3. 数据目录迁移(bareos-sd.d/device/FileStorage.conf 修改):

Device {
  Name = FileStorage
  Media Type = File
  Archive Device = /data/bareos-storage
  Label Media = yes
  Random Access = yes
  Automatic Mount = yes
  Removable Media = no
  Always Open = no
  Count = 10
}

Archive Device 指向专用数据盘挂载点 /data/bareos-storage(目录属主改为 bareos:bareos),与系统盘隔离;改完 reload 并重启 bareos-storage 使新路径生效。

4. 邮件投递落地(bareos-dir.d/messages/Daemon.conf 与 Standard.conf 修改 mail = 行):

  mail = ops@example.com = all, !skipped, !audit

把收件人从 root 改为运维组邮箱,配合本机 postfix 中继即可收到每日作业报告;无邮件中继的环境保持默认,消息仍可在 bconsole messages 与 /var/log/bareos/bareos.log 查看。

修改完成后统一校验并热加载:

runuser -u bareos -- bareos-dir -t
printf "reload\nquit\n" | bconsole | tail -3

实测回显:

reloaded

七、常见问题(FAQ)

7.1 改了配置 reload 显示 reloaded,但行为没变?

  • 排查:确认改的目录对不对——Job/Pool/Schedule/FileSet 等策略全在 bareos-dir.d/,SD 的落盘路径在 bareos-sd.d/,FD 口令在 bareos-fd.d/;reload 只热加载 Director,SD/FD 侧配置修改需重启对应服务(systemctl restart bareos-storage / bareos-filedaemon);
  • 验证:printf "show <资源类型>\nquit\n" | bconsole 核对内存态值是否更新(见 3.2 节)。

7.2 换了默认 Console 口令后 bconsole 连不上?

  • 根因:bconsole.conf(客户端口令)与 bareos-dir.d/director/bareos-dir.conf(服务端口令)是成对校验的,只改一边必然失配;
  • 解法:两处 Password 同步替换为同一值后 systemctl restart bareos-director。

7.3 Storage 资源的 Address 能写 localhost 吗?

  • 不能。官方配置注释明确「Use a fully qualified name here (do not use "localhost" here)」:Director 侧 Storage 资源的 Address 会被 FD 侧作业用于直连 SD 取/还数据流,单机部署写本机 FQDN 或固定 IP(安装默认把占位符替换成了主机名 bareos-server)。

7.4 目录库连接报 Peer authentication failed?

  • 根因:默认 dbpassword = "" 走 Unix socket peer 认证,要求 OS 用户与数据库用户同名(均为 bareos);
  • 解法:管理命令一律 runuser -u bareos -- <命令>(安装篇 FAQ 8.3 实测);远程数据库场景改为口令认证并补 dbaddress。

7.5 新客户端备份报认证失败?

  • 排查顺序:Director 侧 Client 资源的 Name 与 FD 侧身份是否一致 → 两侧 Password 是否同值(Director 侧 client/XX.conf vs FD 侧 director/bareos-dir.conf)→ FD 服务是否运行(systemctl is-active bareos-filedaemon)→ 网络 9102 是否放行;
  • 定位手段:Director 侧 journalctl -u bareos-director 可见连接与 TLS 报错明细。

八、参考链接