Add borgmatic

This commit is contained in:
uumas
2025-03-31 03:15:14 +03:00
parent 0deed89c3f
commit 0db60e2d60
12 changed files with 344 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
# {{ ansible_managed }}
# vim:ft=yaml
source_directories:
{{ borgmatic_config_directories | to_nice_yaml }}
repositories:
{% for target in borgmatic_config_targets %}
{% for directory in target.directories %}
- path: "ssh://{{ hostvars[target.host].ansible_user_id }}@{{ target.host }}/{{ directory }}/{{ ansible_fqdn }}/{{ borgmatic_config_name }}"
{% endfor %}
{% endfor %}
working_directory: "~"
one_file_system: true
exclude_patterns:
- /var/cache
exclude_caches: true
exclude_if_present:
- .nobackup
keep_exclude_tags: true
source_directories_must_exist: true
compression: zstd
encryption_passphrase: "{{ borgmatic_config_encryption_passphrase }}"
ssh_command: ssh -i ~/.ssh/id_ed25519_borg
keep_within: 48H
keep_hourly: 168
keep_daily: 30
keep_weekly: 26
keep_monthly: {{ (borgmatic_config_keep_backups_months / 2) | round(0, 'ceil') | int }}
keep_yearly: {{ (borgmatic_config_keep_backups_months / 12) | round(0, 'ceil') | int }}

View File

@@ -0,0 +1,21 @@
# {{ ansible_managed }}
[Unit]
Description=Run borgmatic backup
[Timer]
{% if borgmatic_config_backup_frequency.unit == "min" %}
OnCalendar=*:0/{{ borgmatic_config_backup_frequency.amount }}
{% elif borgmatic_config_backup_frequency.unit == "h" %}
OnCalendar=0/{{ borgmatic_config_backup_frequency.amount }}:30
{% elif borgmatic_config_backup_frequency.unit == "d" %}
OnCalendar=*-1/{{ borgmatic_config_backup_frequency.amount }} 22:00
{% else %}
{{ dafuq }}
{% endif %}
Persistent=true
RandomizedDelaySec={{ 10 * borgmatic_config_backup_frequency.amount }}{{ _borgmatic_config_previous_time_unit[borgmatic_config_backup_frequency.unit] }}
FixedRandomDelay=true
[Install]
WantedBy=timers.target