# btrbk.conf
# See btrbk.conf(5) for more details.

{% if btrbk.options.logfile is defined %}
transaction_log {{ btrbk.options.logfile }}
{% endif %}

{% if btrbk.options.syslog is defined %}
transaction_syslog {{ btrbk.options.syslog }}
{% endif %}

{% if btrbk.options.lockfile is defined %}
lockfile {{ btrbk.options.lockfile }}
{% endif %}

{% if btrbk.options.ssh.remote_user is defined %}
ssh_user {{ btrbk.options.ssh.remote_user }}
{% endif %}
{% if btrbk.options.ssh.private_key_path is defined %}
ssh_identity {{ btrbk.options.ssh.private_key_path }}
{% endif %}

{% for type in ['snapshot', 'target', 'archive'] %}

{% if btrbk.options[type].policy is defined %}
{{ type }}_preserve {{ btrbk.options[type].policy }}
{% endif %}
{% if btrbk.options[type].min_age is defined %}
{{ type }}_preserve_min {{ btrbk.options[type].min_age }}
{% endif %}
{% endfor %}

timestamp_format {{ btrbk.options.timestamp_format }}

compat busybox

backend_local_user btrfs-progs-doas
backend_remote     btrfs-progs-doas

stream_compress zstd

{% if btrbk.options.stream_buffer.local is defined %}
stream_buffer {{ btrbk.options.stream_buffer.local }}
{% endif %}
{% if btrbk.options.stream_buffer.remote is defined %}
stream_buffer_remote {{ btrbk.options.stream_buffer.remote }}
{% endif %}

{% for volume in btrbk.volumes %}

volume {{ volume.path }}
    snapshot_dir {{ volume.snapshot_dir }}
{% if volume.archive_exclude_pattern is defined %}
    archive_exclude {{ archive_exclude_pattern }}
{% endif %}
{% if volume.subvolumes is defined %}
{% for subvolume in volume.subvolumes %}
    subvolume {{ subvolume }}
{% endfor %}
{% endif %}
{% if volume.targets is defined %}
{% for target in volume.targets %}
    target {{ target }}
{% endfor %}
{% endif %}
{% endfor %}
