Feat: rename templates and add borgmatic_name

This commit is contained in:
Bertrand Benjamin 2022-03-13 14:36:23 +01:00
parent c23bebed74
commit 2ffabd234a
4 changed files with 9 additions and 6 deletions

View File

@ -30,7 +30,7 @@
- name: Borgmatic config
template:
src: borgmatic.config.yaml.j2
src: config.yaml.j2
dest: "{{ borgmatic_config_file }}"
mode: 644
@ -45,14 +45,14 @@
- name: copy systemd service
template:
src: borgmatic.service.j2
src: service.j2
dest: "/lib/systemd/system/borgmatic_{{ borgmatic_name }}.service"
mode: 644
notify: "reload systemd"
- name: copy systemd timer for executing borgmatic after boot
template:
src: borgmatic.afterboot.timer.j2
src: afterboot.timer.j2
dest: "/lib/systemd/system/borgmatic_{{ borgmatic_name }}.timer"
notify: "reload systemd"

View File

@ -1,3 +1,5 @@
#jinja2: lstrip_blocks: "True", trim_blocks: "True"
{{ ansible_managed | comment }}
[Unit]
Description=Run borgmatic {{ borgmatic_name }} backup

View File

@ -102,7 +102,7 @@ storage:
# also specify a prefix in the retention section to avoid accidental pruning of
# archives with a different archive name format. And you should also specify a
# prefix in the consistency section as well.
archive_name_format: '{hostname}-{now:%Y-%m-%d-%H%M%S}'
archive_name_format: '{hostname}-{{ borgmatic_name }}-{now:%Y-%m-%d-%H%M%S}'
# Bypass Borg error about a repository that has been moved.
relocated_repo_access_is_ok: {{ borgmatic_relocated_repo_access_is_ok }}
@ -149,7 +149,7 @@ retention:
# When pruning, only consider archive names starting with this prefix.
# Borg placeholders can be used. See the output of "borg help placeholders" for
# details. Default is "{hostname}-".
prefix: '{hostname}-'
prefix: '{hostname}-{{ borgmatic_name }}'
# Consistency checks to run after backups. See
# https://borgbackup.readthedocs.org/en/stable/usage.html#borg-check and
@ -174,7 +174,7 @@ consistency:
# When performing the "archives" check, only consider archive names starting with
# this prefix. Borg placeholders can be used. See the output of
# "borg help placeholders" for details. Default is "{hostname}-".
prefix: '{hostname}-'
prefix: '{hostname}-{{ borgmatic_name }}'
# Shell commands or scripts to execute before and after a backup or if an error has occurred.
# IMPORTANT: All provided commands and scripts are executed with user permissions of borgmatic.

View File

@ -1,3 +1,4 @@
#jinja2: lstrip_blocks: "True", trim_blocks: "True"
{{ ansible_managed | comment }}
[Unit]