Featured image of post Borgmatic Configuration

Borgmatic Configuration

Hello Artem!!

Borgmatic is simple, configuration-driven backup software for servers and workstations. It supports incremental backups and deduplication which allow you to save a lot of space.


Borgmatic Configuration

Installation and configuration of borgmatic on Debian

  1. apt install borgmatic

  2. Copy borgmatic config

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
location:
    # List of source directories to backup
    source_directories:
        - /
    
    # Repository with port specification in the URL
    repositories:
        - ssh://user@remote:22/./backups/
    
    # Patterns to exclude from backup
    exclude_patterns:
        - /dev
        - /proc
        - /sys
        - /var/run
        - /run
        - /mnt
        - /tmp

storage:
  archive_name_format: '{hostname}-{now}'
  unknown_unencrypted_repo_access_is_ok: true
  # encryption_passphrase: "yourpasss"
  encryption: none

retention:
    # Retention policy for backups
    keep_daily: 7
    keep_weekly: 4
    keep_monthly: 6
    keep_yearly: 1

consistency:
    checks:
        - repository
        - archives
  1. Check if Borgmatic config is OK
1
2
3
4
5
6
7
# Initialize borg repo
borgmatic init --encryption=none
# Check if borg fetch is successfull
borgmatic list

# Execute test backup (prefferably screen or tmux)
borgmatic
  1. On successfull backup, add as a daily backup service

Edit /etc/systemd/system/borgmatic.service

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[Unit]
Description=Borgmatic system backup
Requires=network.target
After=network.target

[Service]
Type=oneshot
Nice=10
IOSchedulingClass=best-effort
IOSchedulingPriority=6
ProtectSystem=full
ExecStart=/usr/bin/borgmatic --verbosity -1 --syslog-verbosity 1

Edit /etc/systemd/system/borgmatic.timer

Service will start backup at random time, after 24 hours since last execution

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[Unit]
Description=Daily backup timer

[Timer]
OnCalendar=Daily
RandomizedDelaySec=24h
Persistent=true

[Install]
WantedBy=timers.target
  1. Activate the service

systemctl enable borgmatic.timer