eeeeeeeeeeeeeeu

master
omidshj 2025-02-05 21:25:25 +03:30
parent a316fd1ed8
commit 4610c2908c
1 changed files with 15 additions and 5 deletions

View File

@ -11,16 +11,26 @@
--authenticationDatabase admin
--out {{ mongo_backup_dir }}
with_items: "{{ db_names }}"
- name: Get the current weekday
shell: date +%a
register: weekday
changed_when: false
- name: Archive each directory separately
command: >
tar -czf "{{ backup_dir }}/{{ item }}-{{ weekday.stdout }}.tar.gz" -C "{{ backup_dir }}" "{{ item }}"
tar -czf "{{ backup_dir }}/{{server}}-{{mongodb_container}}-{{ item }}.tar.gz" -C "{{ backup_dir }}" "{{ item }}"
loop: "{{ db_names }}"
- name: Delete backed-up directories
file:
path: "{{ backup_dir }}/{{ item }}"
state: absent
loop: "{{ db_names }}"
- name: Get the current weekday
shell: date +%a
register: weekday
changed_when: false
- name: send them to s3
command: >
s3cmd put {{ backup_dir }}/{{server}}-{{mongodb_container}}-{{ item }}.tar.gz
{{ s3_folder }}/{{ weekday.stdout }}/{{ backup_dir }}/{{server}}-{{mongodb_container}}-{{ item }}.tar.gz
with_items: "{{ db_names }}"
- name: Delete backed-up files
file:
path: "{{ backup_dir }}/{{server}}-{{mongodb_container}}-{{ item }}.tar.gz"
state: absent
loop: "{{ db_names }}"