Ver código fonte

add backups_ignore option to cloud-backups role

Blaine Story 3 anos atrás
pai
commit
860ead3ff9

+ 2 - 0
roles/cloud-backups/defaults/main.yml

@@ -0,0 +1,2 @@
+---
+backups_ignore: '::' # string that wouldn't be in a reasonable docker volume mapping

+ 4 - 4
roles/cloud-backups/templates/backup-to-b2.sh.j2

@@ -1,16 +1,15 @@
 #!/bin/bash
 # {{ ansible_managed }}
 
-EMAIL_ADDRESS="root@localhost"
 LOG_FILE="/var/log/rclone/rclone-$(date +%Y-%m-%d).log"
 
-
 {% if backups is defined and 'containers' in backups %}
 {% if containers is defined %}
 {% for container in containers %}
 {% if container.volumes is defined %}
 {% for volume in container.volumes %}
-echo "Starting backup of container '{{ container.service_name }}' volume '{{ volume | regex_replace(':.*') }}'." | ts >> "$LOG_FILE"
+{% if backups_ignore not in volume|regex_replace(':.*') %}
+echo "Starting backup of '{{ container.service_name }}:{{ volume | regex_replace(':.*') }}'." | ts >> "$LOG_FILE"
 /usr/bin/rclone copy {{ volume | regex_replace(':.*') }}/ b2-container-data:current/{{ ansible_hostname }}/{{ container.service_name }}/{{ volume | regex_replace(':.*') | basename }} \
       --backup-dir=b2-container-data:old/{{ ansible_hostname }}/{{ container.service_name }}/{{ volume | regex_replace(':.*') | basename }} \
       --suffix=-$(date +%Y-%m-%d) \
@@ -18,8 +17,9 @@ echo "Starting backup of container '{{ container.service_name }}' volume '{{ vol
       --suffix-keep-extension \
       --exclude "*log" \
       --log-file="$LOG_FILE" -v
-echo "Finished backup of container '{{ container.service_name }}' volume '{{ volume | regex_replace(':.*') }}'." | ts >> "$LOG_FILE"
+echo "Finished backup of '{{ container.service_name }}:{{ volume | regex_replace(':.*') }}'." | ts >> "$LOG_FILE"
 
+{% endif %}
 {% endfor %}
 {% endif %}
 {% endfor %}