Add ability to exclude from s3backup.sh, lay out gameserver backups more nicely to respect this

This commit is contained in:
Salt 2020-12-29 08:35:41 -06:00
parent 978ffc21ac
commit eb97eb4a7a
3 changed files with 13 additions and 1 deletions

View File

@ -7,9 +7,12 @@
- role: backup
vars:
backup_s3backup_list_extra:
- /opt/minecraft/valhelsia/world
- /opt/minecraft/valhelsia
- /opt/minecraft/vanilla
- /opt/factorio
backup_s3backup_exclude_list_extra:
- /opt/minecraft/valhelsia/backups
- /opt/minecraft/vanilla/backups
become: yes
tags: [ backup ]
- role: minecraft

View File

@ -19,6 +19,9 @@ backup_s3_aws_secret_access_key: REPLACEME
# If you want it to do that, end the path with a slash!
backup_s3backup_list: []
backup_s3backup_list_extra: []
# List of files/directories to --exclude
backup_s3backup_exclude_list: []
backup_s3backup_exclude_list_extra: []
# Arguments to pass to tar
# Note that passing f here is probably a bad idea
backup_s3backup_tar_args: cz

View File

@ -52,6 +52,12 @@ for dir in "${DIRS[@]}"; do
done
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 %}
--exclude "{{ item }}" \
{% endfor %}
| aws s3 cp - \
"s3://{{ backup_s3_bucket }}/{{ inventory_hostname_short }}/$(date "+{{ backup_dateformat }}").tar.gz"