|
@@ -8,7 +8,14 @@
|
|
|
backup_command: |-
|
|
|
target_path="{{item.target_dir_path}}/$(date -u +'\%Y-\%m-\%dT\%H:\%M:\%SZ').sql"; previous_path="{{item.target_dir_path}}/$(ls --sort=time --format=single-column "{{item.target_dir_path}}" | head --lines 1)";
|
|
|
{%- if item.source_host is defined %}
|
|
|
- ssh -i {{item.ssh_key_path}} {{item.ssh_user}}@{{item.source_host}}
|
|
|
+ ssh
|
|
|
+ {%- if item.ssh_key_path is defined %}
|
|
|
+ -o IdentityFile='{{item.ssh_key_path}}'
|
|
|
+ {%- endif %}
|
|
|
+ {%- if item.ssh_user is defined %}
|
|
|
+ -o User={{item.ssh_user}}
|
|
|
+ {%- endif %}
|
|
|
+ {{item.source_host}}
|
|
|
{%- endif %}
|
|
|
/usr/bin/mysqldump --opt --order-by-primary --skip-dump-date {{item.database}} | sed 's$),($),\n($g' >"$target_path"; [ "$previous_path" ] && cmp --quiet "$previous_path" "$target_path" && rm "$target_path"
|
|
|
with_items: '{{mysql_backups}}'
|