Skip to main content
  1. Posts/

Backup Incus with Borgmatic

·228 words·2 mins

At the time of writing, Incus itself does not offer a backup scheduling feature. However, the Incus CLI has an export command for instances and storage pool volumes that can be used to create a gzip archive for an instance or storage pool volume.

Since I use Borgmatic for backups, we can configure it so that certain instances or storage pool volumes are exported to a specific location before the backup and are cleaned up after the backup.

Note: Borgmatic v2+ has a new configuration format for command hooks. Debian 13 offers version 1.9, which is why I am using the earlier approach with before_backup and after_backup.

Here is an example configuration for /etc/borgmatic/config.yaml that creates the archives before the backup and cleans them up after the backup:

---
source_directories:
  - /srv/incus/backups

repositories:
  - path: /var/lib/backups/local.borg
    label: local

encryption_passphrase: "<your-passphrase>"

compression: auto,zstd

keep_daily: 7
keep_weekly: 4
keep_monthly: 6
keep_yearly: 1

checks:
  - name: repository
  - name: archives
    frequency: 2 weeks

before_backup:
  - incus export a1 --instance-only /srv/incus/backups/a1.tar.gz
  - incus storage volume export default a1-data /srv/incus/backups/a1-data.tar.gz

after_backup:
  - rm /srv/incus/backups/*.tar.gz

Since Borgmatic version 1.9.3, Borgmatic supports creating snapshots with the ZFS file system and sending these snapshots to Borg for backup. This would also be an interesting approach to use the ZFS datasets created by Incus to back up the data, but I have not tested this yet :).