From 2d514314882641f162a9799c1b5e2bb553c4eb78 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Sat, 16 Feb 2019 11:44:31 -0500 Subject: [PATCH] Initialize an empty borg repository This is the next step to get borgbackup / borgmatic working. Change-Id: Ib1dc15fbd251262cf527a7cec8e86d9212e65fbb Signed-off-by: Paul Belanger --- config/borgmatic/config.yaml.j2 | 35 ++++++++++++++++++++++++++ inventory/testing/group_vars/all.yaml | 17 +++++++++++++ inventory/testing/group_vars/borg.yaml | 2 ++ playbooks/borg-client.yaml | 7 ++++++ 4 files changed, 61 insertions(+) create mode 100644 config/borgmatic/config.yaml.j2 create mode 100644 inventory/testing/group_vars/all.yaml diff --git a/config/borgmatic/config.yaml.j2 b/config/borgmatic/config.yaml.j2 new file mode 100644 index 0000000..c84d23d --- /dev/null +++ b/config/borgmatic/config.yaml.j2 @@ -0,0 +1,35 @@ +# This file is generated by Ansible +# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN +# +--- +location: + # List of source directories to backup. Globs are expanded. + source_directories: + - /home + + # Paths to local or remote repositories. + repositories: +{% if 'borg-server' in groups %} +{% for host in groups['borg-server'] %} + - borg_{{ inventory_hostname }}@{{ hostvars[host].ansible_host }}:backup.borg +{% endfor %} +{% endif %} + + local_path: {{ borgbackup_pip_virtualenv }}/bin/borg + +storage: + # WARNING! Be sure to change this value, otherwise when you initialize + # a borg repo, it will default to public secret! + encryption_passphrase: SuperSecretPassphrase + +retention: + # Retention policy for how many backups to keep in each category. + keep_daily: 7 + keep_weekly: 4 + keep_monthly: 6 + +consistency: + # List of consistency checks to run: "repository", "archives", or both. + checks: + - repository + - archives diff --git a/inventory/testing/group_vars/all.yaml b/inventory/testing/group_vars/all.yaml new file mode 100644 index 0000000..cc2d484 --- /dev/null +++ b/inventory/testing/group_vars/all.yaml @@ -0,0 +1,17 @@ +# Copyright 2019 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +--- +# windmill-config +# TODO(pabelanger): Create windmill-config project on git.o.o. +windmill_config_git_dest: "{{ lookup('pipe', 'pwd') | dirname }}/config" diff --git a/inventory/testing/group_vars/borg.yaml b/inventory/testing/group_vars/borg.yaml index c149a55..8d5b992 100644 --- a/inventory/testing/group_vars/borg.yaml +++ b/inventory/testing/group_vars/borg.yaml @@ -22,3 +22,5 @@ borgmatic_pip_virtualenv: /opt/venv/borgmatic borgmatic_user_name: borgbackup borgmatic_user_group: borgbackup borgmatic_user_home: /var/lib/borgbackup + +borgmatic_file_config_yaml_src: "{{ windmill_config_git_dest }}/borgmatic/config.yaml.j2" diff --git a/playbooks/borg-client.yaml b/playbooks/borg-client.yaml index 2d7b6e9..e33f250 100644 --- a/playbooks/borg-client.yaml +++ b/playbooks/borg-client.yaml @@ -71,3 +71,10 @@ ssh_user_group: borgbackup with_inventory_hostnames: - borg-server:!disabled + + - name: Initialize an empty borg repository + become: true + become_user: borgbackup + command: "{{ borgmatic_pip_virtualenv }}/bin/borgmatic --init --encryption repokey" + register: r + changed_when: r.stderr | length > 0