Extend cleanup of original backup files and do the logrotate.
This commit is contained in:
60
odroid.yaml
60
odroid.yaml
@@ -78,30 +78,6 @@
|
|||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.item[0] }} {{ item.item[1] }}"
|
label: "{{ item.item[0] }} {{ item.item[1] }}"
|
||||||
|
|
||||||
- name: Store the yearly backups
|
|
||||||
copy:
|
|
||||||
remote_src: true
|
|
||||||
src: "{{ backup_dir }}/{{ item }}/{{ ansible_date_time.iso8601_basic_short }}.sql.gz"
|
|
||||||
dest: "{{ backup_dir }}/{{ item }}/yearly/{{ ansible_date_time.iso8601_basic_short }}.sql.gz"
|
|
||||||
loop: "{{ databases }}"
|
|
||||||
when: (ansible_date_time.day == "01" and ansible_data_time.month == "01")
|
|
||||||
|
|
||||||
- name: Store the monthly backups
|
|
||||||
copy:
|
|
||||||
remote_src: true
|
|
||||||
src: "{{ backup_dir }}/{{ item }}/{{ ansible_date_time.iso8601_basic_short }}.sql.gz"
|
|
||||||
dest: "{{ backup_dir }}/{{ item }}/monthly/{{ ansible_date_time.iso8601_basic_short }}.sql.gz"
|
|
||||||
loop: "{{ databases }}"
|
|
||||||
when: (ansible_date_time.day == "01" and ansible_data_time.month != "01")
|
|
||||||
|
|
||||||
- name: Store the weekly backups
|
|
||||||
copy:
|
|
||||||
remote_src: true
|
|
||||||
src: "{{ backup_dir }}/{{ item }}/{{ ansible_date_time.iso8601_basic_short }}.sql.gz"
|
|
||||||
dest: "{{ backup_dir }}/{{ item }}/weekly/{{ ansible_date_time.iso8601_basic_short }}.sql.gz"
|
|
||||||
loop: "{{ databases }}"
|
|
||||||
when: (ansible_date_time.weekday_number == "7")
|
|
||||||
|
|
||||||
- name: Search for the created backups
|
- name: Search for the created backups
|
||||||
find:
|
find:
|
||||||
paths: "{{ backup_dir }}/{{ item }}"
|
paths: "{{ backup_dir }}/{{ item }}"
|
||||||
@@ -111,6 +87,36 @@
|
|||||||
register: backup_files
|
register: backup_files
|
||||||
loop: "{{ systems }}"
|
loop: "{{ systems }}"
|
||||||
|
|
||||||
|
- name: Store the yearly backups
|
||||||
|
copy:
|
||||||
|
remote_src: true
|
||||||
|
src: "{{ item.path }}"
|
||||||
|
dest: "{{ item.path | dirname }}/yearly/{{ item.path | basename }}"
|
||||||
|
with_items: "{{ backup_files.results | map(attribute='files') | list }}"
|
||||||
|
when: (ansible_date_time.day == "01" and ansible_data_time.month == "01")
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.path }}"
|
||||||
|
|
||||||
|
- name: Store the monthly backups
|
||||||
|
copy:
|
||||||
|
remote_src: true
|
||||||
|
src: "{{ item.path }}"
|
||||||
|
dest: "{{ item.path | dirname }}/monthly/{{ item.path | basename }}"
|
||||||
|
with_items: "{{ backup_files.results | map(attribute='files') | list }}"
|
||||||
|
when: (ansible_date_time.day == "01" and ansible_data_time.month != "01")
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.path }}"
|
||||||
|
|
||||||
|
- name: Store the weekly backups
|
||||||
|
copy:
|
||||||
|
remote_src: true
|
||||||
|
src: "{{ item.path }}"
|
||||||
|
dest: "{{ item.path | dirname }}/weekly/{{ item.path | basename }}"
|
||||||
|
with_items: "{{ backup_files.results | map(attribute='files') | list }}"
|
||||||
|
when: (ansible_date_time.weekday_number == "7")
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.path }}"
|
||||||
|
|
||||||
- name: Store the daily backup
|
- name: Store the daily backup
|
||||||
copy:
|
copy:
|
||||||
remote_src: true
|
remote_src: true
|
||||||
@@ -123,9 +129,11 @@
|
|||||||
|
|
||||||
- name: Cleanup original backup files
|
- name: Cleanup original backup files
|
||||||
file:
|
file:
|
||||||
path: "{{ backup_dir }}/{{ item }}/*"
|
path: "{{ item.path }}"
|
||||||
state: absent
|
state: absent
|
||||||
loop: "{{ systems }}"
|
with_items: "{{ backup_files.results | map(attribute='files') | list }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.path }}"
|
||||||
|
|
||||||
- name: Find old daily backups
|
- name: Find old daily backups
|
||||||
find:
|
find:
|
||||||
|
|||||||
Reference in New Issue
Block a user