Concatenate JINJA for loops, echo back ignored directories in backup script

This commit is contained in:
Salt 2020-12-29 08:43:42 -06:00
parent eb97eb4a7a
commit 1933ba21c0

View File

@ -26,11 +26,7 @@ set -e
# We use a bash array because it affords us some level of sanitization, enough
# to let us back up items whose paths contain spaces
declare -a DIRS
{% for item in backup_s3backup_list %}
DIRS+=("{{ item }}")
{% endfor %}
# Extra, probably host-specific directories
{% for item in backup_s3backup_list_extra %}
{% for item in backup_s3backup_list + backup_s3backup_list_extra %}
DIRS+=("{{ item }}")
{% endfor %}
# End directories
@ -50,12 +46,13 @@ echo "Commencing backup on the following items:"
for dir in "${DIRS[@]}"; do
echo "- $dir"
done
echo "Will ignore the following items:"
{% for item in backup_s3backup_exclude_list + backup_s3backup_exclude_list_extra %}
echo "- {{ item }}"
{% endfor %}
echo "Will upload resultant backup to {{ backup_s3_bucket }}"
nice -n 10 tar {{ backup_s3backup_tar_args }}{{ backup_s3backup_tar_args_extra }} "${DIRS[@]}" \
{% for item in backup_s3backup_exclude_list %}
--exclude "{{ item }}" \
{% endfor %}
{% for item in backup_s3backup_exclude_list_extra %}
{% for item in backup_s3backup_exclude_list + backup_s3backup_exclude_list_extra %}
--exclude "{{ item }}" \
{% endfor %}
| aws s3 cp - \