Ansible Role borg_local
This role installs and configures borg and sets up the desired backup repositories in a local directory.
Note that if ClamAV (clamd@scan.service
) is found on the host, it will be temporarily disabled during the backup.
To restore from a backup:
mkdir -p /mnt/borg
source /etc/borg/borg.conf
BORG_REPO="$BACKUP_DIR/daily" # or hourly or on-demand
borg mount "$BORG_REPO" /mnt/borg
cd /mnt/borg/20240101/backup/mariadb-dump
ll -h
cp -a /mnt/borg/20240101/backup/mariadb-dump /restore
# clean up (else the next backup fails)
umount /mnt/borg
Mandatory Role Variables
Variable |
Description |
---|---|
|
Passphrase for the Borg repositories. |
Example:
# mandatory
borg_local__passphrase: 'linuxfabrik'
Optional Role Variables
Variable |
Description |
Default Value |
---|---|---|
|
The directory where the backup repositories will be created. |
|
|
The list of options used by borg. Subkeys:
|
|
|
The list of files or direcotries which should be excluded from the backup. Subkeys:
|
|
|
The URL of the Icinga2 API (usually on the Icinga2 Master). This will be used to set a downtime for the corresponding ClamAV service. |
|
|
The Icinga2 API User to set the downtime for the corresponding ClamAV service. |
unset |
|
The hostname of the Icinga2 host on which the downtime should be set. |
|
|
The list of files or directories which should be included in the backup. Subkeys:
|
|
|
The hour of the daily backup |
|
|
The time at which the daily backup will run. Once per day. |
|
|
The time at which the hourly backup will run. Once per hour. |
|
|
The number of daily backups to keep. |
|
|
The number of hourly backups to keep. |
|
|
Whether the daily backup should be enabled. |
|
|
Whether the hourly backup should be enabled. |
|
Example:
# optional
borg_local__backup_dir: '/backup'
borg_local__backup_opts__host_var:
- option: '--stats'
- option: '--progress'
- option: '--one-file-system'
- option: '--compression lz4'
- option: '--checkpoint-interval 86400'
borg_local__exclude_files__host_var:
- file: '/root/.cache'
- file: '*.svn*'
- file: '*.git*'
- file: '*.tmp'
- file: '*.temp'
- file: '*/cache/*'
- file: '*/log/*'
borg_local__icinga2_api_url: 'https://icinga.example.com:5665'
borg_local__icinga2_api_user_login:
username: 'downtime-user'
password: 'linuxfabrik'
borg_local__icinga2_hostname: 'myhost.example.com'
borg_local__include_files__host_var:
- file: '/etc'
- file: '/home'
- file: '/opt'
- file: '/root'
- file: '/var/spool/cron'
borg_local__on_calendar_daily: '*-*-* {{ borg_local__on_calendar_daily_hour }}:{{ 45 | random(seed=inventory_hostname) }}'
borg_local__on_calendar_daily_hour: 23
borg_local__on_calendar_hourly: '*-*-* *:{{ 59 | random(start=45) }}'
borg_local__retention_daily: '14d'
borg_local__retention_hourly: '99H'
borg_local__timer_daily_enabled: true
borg_local__timer_hourly_enabled: false