X Tutup
Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit a7d8418

Browse files
committed
Backup: Cleaner looking tarball creation task [ansible]
1 parent 915f6a3 commit a7d8418

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

roles/backup/tasks/main.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
- "/opt/systemd-backup"
8181
- "/opt/crontab-backup"
8282

83+
# Backup config files
8384
- name: "Copy files to '{{ local.destination }}'"
8485
copy:
8586
src: "{{ item }}"
@@ -97,6 +98,7 @@
9798
- "/home/{{ user }}/.config/rclone/rclone.conf"
9899
ignore_errors: yes
99100

101+
# Backup the excludes list if it exists
100102
- name: "Look for 'backup_excludes_list.txt' file in cloudbox folder"
101103
stat:
102104
path: "{{ playbook_dir }}/backup_excludes_list.txt"
@@ -112,6 +114,13 @@
112114
force: yes
113115
when: (backup_excludes_list.stat.exists)
114116

117+
- name: Set 'backup_excludes_list_path' variable
118+
set_fact:
119+
backup_excludes_list_path: "{{
120+
(playbook_dir + '/backup_excludes_list.txt')
121+
if ((backup_excludes_list is defined) and (backup_excludes_list.stat.exists))
122+
else (playbook_dir + '/roles/backup/files/backup_excludes_list.txt') }}"
123+
115124
- name: Cloudbox Restore Service
116125
import_tasks: "restore_service.yml"
117126
when: restore_service_enabled
@@ -305,7 +314,7 @@
305314
--ignore-failed-read \
306315
--warning=no-file-changed \
307316
--warning=no-file-removed \
308-
--exclude-from '{{ (backup_excludes_list is defined and backup_excludes_list.stat.exists) | ternary(playbook_dir + '/backup_excludes_list.txt', playbook_dir + '/roles/backup/files/backup_excludes_list.txt') }}' \
317+
--exclude-from '{{ backup_excludes_list_path }}' \
309318
-cf '{{ local.destination }}/opt/{{ item | basename }}.tar' -C '{{ item | dirname }}' './{{ item | basename }}' \
310319
2> /dev/null
311320
args:

roles/backup/tasks/variables.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
# GNU General Public License v3.0 #
99
#########################################################################
1010
---
11-
# Set basic variable(s)
11+
# Set 'user' variable
1212
- name: "Get 'cloudbox.yml' info."
1313
stat:
1414
path: "{{ playbook_dir }}/backup.yml"
1515
register: backup_yml
1616

17-
- name: Set variables
17+
- name: Set 'user' variable
1818
set_fact:
1919
user: "{{ backup_yml.stat.pw_name }}"
2020

@@ -31,6 +31,7 @@
3131
rclone: "{{ rclone | combine(rclone_tmp) }}"
3232
rsync: "{{ rsync | combine(rsync_tmp) }}"
3333

34+
# Restore service
3435
- name: "Set 'restore_service_enabled' variable"
3536
set_fact:
3637
restore_service_enabled: "{{ true if not(

0 commit comments

Comments
 (0)
X Tutup