From 786506d9021af2b44702bed86314a9b13af9e139 Mon Sep 17 00:00:00 2001 From: mg Date: Tue, 22 Dec 2020 12:23:10 +0100 Subject: [PATCH] restic: exclude als Variable (#7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit restic: exclude als Variable --------- Template Datei gelöscht Variablen angelegt Aufgabe mit blockinfile statt template Co-authored-by: Michael Grote <38253905+quotengrote@users.noreply.github.com> Reviewed-on: https://git.mgrote.net/mg/ansible/pulls/7 --- group_vars/all.yml | 12 ++++++++++++ roles/mgrote.restic/defaults/main.yml | 7 +++++++ roles/mgrote.restic/tasks/main.yml | 10 ++++++---- roles/mgrote.restic/templates/exclude.txt | 10 ---------- 4 files changed, 25 insertions(+), 14 deletions(-) delete mode 100644 roles/mgrote.restic/templates/exclude.txt diff --git a/group_vars/all.yml b/group_vars/all.yml index 752a9919..bec80160 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -18,6 +18,18 @@ restic_mount: "/mnt/restic" restic_mount_user: restic restic_mount_password: "{{ lookup('keepass', 'fileserver_smb_user_restic', 'password') }}" + restic_exclude: | + ._* + desktop.ini + .Trash-* + **/**cache***/** + **/**Cache***/** + **/**AppData***/** + /var/lib/docker/volumes/***Musik*** + /var/lib/docker/volumes/***musik*** + # https://github.com/restic/restic/issues/1005 + # https://forum.restic.net/t/exclude-syntax-confusion/1531/12 + ### mgrote.tmux tmux_conf_destination: "/home/mg/.tmux.conf" tmux_bashrc_destination: "/home/mg/.bashrc" diff --git a/roles/mgrote.restic/defaults/main.yml b/roles/mgrote.restic/defaults/main.yml index dfecf964..e6830f8c 100644 --- a/roles/mgrote.restic/defaults/main.yml +++ b/roles/mgrote.restic/defaults/main.yml @@ -1,2 +1,9 @@ --- restic_folders_to_backup: "/usr/local /etc /root /var/www /home" + restic_exclude: | + ._* + desktop.ini + .Trash-* + **/**cache***/** + **/**Cache***/** + **/**AppData***/** diff --git a/roles/mgrote.restic/tasks/main.yml b/roles/mgrote.restic/tasks/main.yml index 543624ea..6dbf54cc 100644 --- a/roles/mgrote.restic/tasks/main.yml +++ b/roles/mgrote.restic/tasks/main.yml @@ -37,11 +37,13 @@ dest: "/usr/local/bin/restic_backup.sh" mode: a+x - - name: copy exclude.txt + - name: create exclude.txt become: yes - ansible.builtin.template: - src: "exclude.txt" - dest: "/etc/restic/exclude.txt" + ansible.builtin.blockinfile: + path: "/etc/restic/exclude.txt" + create: yes + block: "{{ restic_exclude }}" + mode: 0644 - name: copy password.txt become: yes diff --git a/roles/mgrote.restic/templates/exclude.txt b/roles/mgrote.restic/templates/exclude.txt deleted file mode 100644 index b4298a60..00000000 --- a/roles/mgrote.restic/templates/exclude.txt +++ /dev/null @@ -1,10 +0,0 @@ -._* -desktop.ini -.Trash-* -**/**cache***/** -**/**Cache***/** -**/**AppData***/** -/var/lib/docker/volumes/***Musik*** -/var/lib/docker/volumes/***musik*** -# https://github.com/restic/restic/issues/1005 -# https://forum.restic.net/t/exclude-syntax-confusion/1531/12