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_compression: "zstd"
borgbackup_exclude_dirs: borgbackup_exclude_dirs:
- sh:/home/*/.gvfs - sh:/home/*/.gvfs
...@@ -30,6 +32,7 @@ borgbackup_exclude_dirs: ...@@ -30,6 +32,7 @@ borgbackup_exclude_dirs:
- sh:/home/*/**/bower_components - sh:/home/*/**/bower_components
borgbackup_pool: "/mnt/borgpool" borgbackup_pool: "/mnt/borgpool"
borgbackup_repo_path: "backup"
borgbackup_keep_within: 7d borgbackup_keep_within: 7d
borgbackup_keep_daily: 21 borgbackup_keep_daily: 21
borgbackup_keep_weekly: 8 borgbackup_keep_weekly: 8
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
- name: Check if Repo already exists - name: Check if Repo already exists
stat: stat:
path: "{{ borgbackup_pool }}/{{ ansible_hostname }}/backup" path: "{{ borgbackup_pool }}/{{ ansible_hostname }}/{{ borgbackup_repo_path }}"
register: repo register: repo
delegate_to: "{{ borgbackup_target_host }}" delegate_to: "{{ borgbackup_target_host }}"
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
key: "{{ borgbackup_target_ip }} ssh-ed25519 {{ hostvars[borgbackup_target_host]['ansible_ssh_host_key_ed25519_public'] }}" key: "{{ borgbackup_target_ip }} ssh-ed25519 {{ hostvars[borgbackup_target_host]['ansible_ssh_host_key_ed25519_public'] }}"
- name: Create Borg Repo - 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: environment:
BORG_PASSPHRASE: "{{ borgbackup_key }}" BORG_PASSPHRASE: "{{ borgbackup_key }}"
when: not repo.stat.exists when: not repo.stat.exists
......
--- ---
- name: Create Group - name: Create Group
group: group:
name: "borgbackup" name: "{{ borgbackup_target_group }}"
ignore_errors: true ignore_errors: true
register: create_group register: create_group
- name: Create Group Fallback - name: Create Group Fallback
command: addgroup borgbackup command: "addgroup {{ borgbackup_target_group }}"
register: create_group_fallback register: create_group_fallback
failed_when: failed_when:
- create_group_fallback.rc != 0 - create_group_fallback.rc != 0
...@@ -16,13 +16,13 @@ ...@@ -16,13 +16,13 @@
- name: Create User - name: Create User
user: user:
name: "borgbackup" name: "{{ borgbackup_target_user }}"
group: "borgbackup" group: "{{ borgbackup_target_group }}"
ignore_errors: true ignore_errors: true
register: create_user register: create_user
- name: Create User Fallback - name: Create User Fallback
command: adduser -D -G borgbackup borgbackup command: "adduser -D -G {{ borgbackup_target_group }} {{ borgbackup_target_user }}"
register: create_user_fallback register: create_user_fallback
failed_when: failed_when:
- create_user_fallback.rc != 0 - create_user_fallback.rc != 0
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
- name: Set permissions - name: Set permissions
file: file:
path: "{{ item }}" path: "{{ item }}"
owner: "borgbackup" owner: "{{ borgbackup_target_user }}"
group: "borgbackup" group: "{{ borgbackup_target_group }}"
mode: 0700 mode: 0700
state: directory state: directory
with_items: with_items:
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
- name: Add public key - name: Add public key
authorized_key: authorized_key:
user: "borgbackup" user: "{{ borgbackup_target_user }}"
key: "{{ borgbackup_source_key }}" key: "{{ borgbackup_source_key }}"
# yamllint disable-line rule:line-length # 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" 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: ...@@ -7,7 +7,7 @@ location:
# Paths to local or remote repositories. # Paths to local or remote repositories.
repositories: repositories:
- borgbackup@{{ borgbackup_target_ip }}:backup - "{{ borgbackup_target_user }}@{{ borgbackup_target_ip }}:{{ borgbackup_repo_path }}"
exclude_patterns: exclude_patterns:
{% for item in borgbackup_exclude_dirs %} {% for item in borgbackup_exclude_dirs %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment