diff --git a/mongo backup.yml b/mongo backup.yml index 263c096..21d46fe 100644 --- a/mongo backup.yml +++ b/mongo backup.yml @@ -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 }}" \ No newline at end of file