Skip to content
Snippets Groups Projects
Verified Commit 1bdfe4cf authored by David Mehren's avatar David Mehren
Browse files

Make more target details configurable

parent 73264667
No related branches found
No related tags found
No related merge requests found
---
borgbackup_target_group: borgbackup
borgbackup_target_user: borgbackup
borgbackup_compression: "zstd"
borgbackup_exclude_dirs:
- sh:/home/*/.gvfs
......@@ -30,6 +32,7 @@ borgbackup_exclude_dirs:
- sh:/home/*/**/bower_components
borgbackup_pool: "/mnt/borgpool"
borgbackup_repo_path: "backup"
borgbackup_keep_within: 7d
borgbackup_keep_daily: 21
borgbackup_keep_weekly: 8
......
......@@ -17,7 +17,7 @@
- name: Check if Repo already exists
stat:
path: "{{ borgbackup_pool }}/{{ ansible_hostname }}/backup"
path: "{{ borgbackup_pool }}/{{ ansible_hostname }}/{{ borgbackup_repo_path }}"
register: repo
delegate_to: "{{ borgbackup_target_host }}"
......@@ -37,7 +37,7 @@
key: "{{ borgbackup_target_ip }} ssh-ed25519 {{ hostvars[borgbackup_target_host]['ansible_ssh_host_key_ed25519_public'] }}"
- name: Create Borg Repo
command: "borg init -e repokey borgbackup@{{ borgbackup_target_ip }}:backup"
command: "borg init -e repokey {{ borgbackup_target_user }}@{{ borgbackup_target_ip }}:{{ borgbackup_repo_path }}"
environment:
BORG_PASSPHRASE: "{{ borgbackup_key }}"
when: not repo.stat.exists
......
---
- name: Create Group
group:
name: "borgbackup"
name: "{{ borgbackup_target_group }}"
ignore_errors: true
register: create_group
- name: Create Group Fallback
command: addgroup borgbackup
command: "addgroup {{ borgbackup_target_group }}"
register: create_group_fallback
failed_when:
- create_group_fallback.rc != 0
......@@ -16,13 +16,13 @@
- name: Create User
user:
name: "borgbackup"
group: "borgbackup"
name: "{{ borgbackup_target_user }}"
group: "{{ borgbackup_target_group }}"
ignore_errors: true
register: create_user
- name: Create User Fallback
command: adduser -D -G borgbackup borgbackup
command: "adduser -D -G {{ borgbackup_target_group }} {{ borgbackup_target_user }}"
register: create_user_fallback
failed_when:
- create_user_fallback.rc != 0
......@@ -33,8 +33,8 @@
- name: Set permissions
file:
path: "{{ item }}"
owner: "borgbackup"
group: "borgbackup"
owner: "{{ borgbackup_target_user }}"
group: "{{ borgbackup_target_group }}"
mode: 0700
state: directory
with_items:
......@@ -43,7 +43,7 @@
- name: Add public key
authorized_key:
user: "borgbackup"
user: "{{ borgbackup_target_user }}"
key: "{{ borgbackup_source_key }}"
# yamllint disable-line rule:line-length
key_options: "command=\"cd {{ hostvars[borgbackup_target_host]['borgbackup_pool'] | default(borgbackup_pool) }}/{{ borgbackup_source_host }};borg serve --restrict-to-path {{ hostvars[borgbackup_target_host]['borgbackup_pool'] | default(borgbackup_pool) }}/{{ borgbackup_source_host }}\",restrict"
......@@ -7,7 +7,7 @@ location:
# Paths to local or remote repositories.
repositories:
- borgbackup@{{ borgbackup_target_ip }}:backup
- "{{ borgbackup_target_user }}@{{ borgbackup_target_ip }}:{{ borgbackup_repo_path }}"
exclude_patterns:
{% for item in borgbackup_exclude_dirs %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment