Skip to content

Commit

Permalink
Change backup_env from a list to a dict
Browse files Browse the repository at this point in the history
  • Loading branch information
boutetnico committed Jan 22, 2024
1 parent 90729d0 commit 9bcc0ef
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Role Variables
| backup_temp_dir | yes | `{{ backup_home_dir }}/temp` | string | |
| backup_extra_dir | yes | `[]` | list | Create additional directories if needed |
| backup_dependencies | yes | `[cron, gzip, tar, util-linux]` | list | |
| backup_env | yes | `[]` | list | |
| backup_env | yes | `{}` | dict | |
| backup_archive_enabled | yes | `true` | bool | Wether or not to pack files into an archive |
| backup_compression_enabled | yes | `true` | bool | Wether or not to compress the archive file |
| backup_compressor | yes | `gzip` | string | |
Expand Down
8 changes: 4 additions & 4 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ backup_dependencies:
- util-linux

# Add environnement variables to backup scripts
backup_env: []
# - PATH="$PATH:/usr/local/bin"
# - RESTIC_REPOSITORY=/srv/restic-repo
# - RESTIC_PASSWORD=_secret_
backup_env: {}
# PATH: "$PATH:/usr/local/bin"
# RESTIC_REPOSITORY: /srv/restic-repo
# RESTIC_PASSWORD: _secret_

backup_archive_enabled: true

Expand Down
4 changes: 2 additions & 2 deletions templates/docker_mariabackup.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ MYSQL_PASSWORD={{ item.vars.mysql_password }}
MARIABACKUP_DOCKER_IMAGE={{ item.vars.mariabackup_docker_image }}
MARIABACKUP_OPTIONS="{{ item.vars.mariabackup_options | d('') }}"

{% for item in backup_env %}
export {{ item }}
{% for key, value in backup_env.items() %}
export {{ key }}={{ value }}
{% endfor %}

finish() {
Expand Down
4 changes: 2 additions & 2 deletions templates/files.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ FILES_PATH={{ item.vars.files_path }}
DATE=$(date +%Y%m%dT%H%M%S)
DEST_FILE={{ backup_temp_dir }}/${SERVICE}-${DATE}.tar

{% for item in backup_env %}
export {{ item }}
{% for key, value in backup_env.items() %}
export {{ key }}={{ value }}
{% endfor %}

finish() {
Expand Down
4 changes: 2 additions & 2 deletions templates/influxdb.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ INFLUXDB_HOST="{{ item.vars.influxdb_host }}"
INFLUXDB_TOKEN="{{ item.vars.influxdb_token }}"
INFLUXDB_OPTIONS="{{ item.vars.influxdb_options | d('') }}"

{% for item in backup_env %}
export {{ item }}
{% for key, value in backup_env.items() %}
export {{ key }}={{ value }}
{% endfor %}

finish() {
Expand Down
4 changes: 2 additions & 2 deletions templates/mongodump.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ MONGODB_ENDPOINT={{ item.vars.mongodb_endpoint }}
MONGODB_USER={{ item.vars.mongodb_user }}
MONGODB_PASSWORD={{ item.vars.mongodb_password }}

{% for item in backup_env %}
export {{ item }}
{% for key, value in backup_env.items() %}
export {{ key }}={{ value }}
{% endfor %}

finish() {
Expand Down
4 changes: 2 additions & 2 deletions templates/mysqldump.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ MYSQL_ENDPOINT={{ item.vars.mysql_endpoint }}
MYSQL_USER={{ item.vars.mysql_user }}
MYSQL_PASSWORD={{ item.vars.mysql_password }}

{% for item in backup_env %}
export {{ item }}
{% for key, value in backup_env.items() %}
export {{ key }}={{ value }}
{% endfor %}

finish() {
Expand Down
4 changes: 2 additions & 2 deletions templates/s3_bucket.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ DEST_FILE={{ backup_temp_dir }}/${SERVICE}-${DATE}.tar
BUCKET_NAME={{ item.vars.bucket_name }}
S3_SYNC_PATH={{ item.vars.s3_sync_path }}

{% for item in backup_env %}
export {{ item }}
{% for key, value in backup_env.items() %}
export {{ key }}={{ value }}
{% endfor %}

finish() {
Expand Down
4 changes: 2 additions & 2 deletions templates/xtrabackup.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ MYSQL_PASSWORD={{ item.vars.mysql_password }}
XTRABACKUP_BACKUP_OPTIONS="{{ item.vars.xtrabackup_backup_options | d('') }}"
XTRABACKUP_PREPARE_OPTIONS="{{ item.vars.xtrabackup_prepare_options | d('') }}"

{% for item in backup_env %}
export {{ item }}
{% for key, value in backup_env.items() %}
export {{ key }}={{ value }}
{% endfor %}

finish() {
Expand Down

0 comments on commit 9bcc0ef

Please sign in to comment.