|
@@ -6,10 +6,11 @@
|
|
# escape %
|
|
# escape %
|
|
# $command .= ' | sed \'s/ AUTO_INCREMENT=[0-9]*\b//\'';
|
|
# $command .= ' | sed \'s/ AUTO_INCREMENT=[0-9]*\b//\'';
|
|
backup_command: |-
|
|
backup_command: |-
|
|
- {% if item.source_host is defined %}
|
|
|
|
- ssh -i {{item.ssh_key_path}} {{item.ssh_user}}@{{item.source_host}}
|
|
|
|
|
|
+ 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}}
|
|
{%- endif %}
|
|
{%- endif %}
|
|
- /usr/bin/mysqldump --opt --order-by-primary --skip-dump-date {{item.database}} | sed 's$),($),\n($g' >"{{item.target_dir_path}}/$(date -u +'\%Y-\%m-\%dT\%H:\%M:\%SZ').sql"
|
|
|
|
|
|
+ /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}}'
|
|
with_items: '{{mysql_backups}}'
|
|
register: mysql_backup_commands
|
|
register: mysql_backup_commands
|
|
- name: setup cron jobs
|
|
- name: setup cron jobs
|