Commit f8e6cfde by nadeemshahzad

added prefix and timestamp(H/M) to backup archive

parent d0e0aa3f
...@@ -2,17 +2,16 @@ ...@@ -2,17 +2,16 @@
hosts: all hosts: all
vars: vars:
splunk_config_dir: "/opt/splunk/etc" splunk_config_dir: "/opt/splunk/etc"
splunk_config_archive: "{{ date }}.tar.gz" splunk_host: "{{ splunk_host_id }}"
splunk_config_archive: "{{ splunk_host }}-{{ date }}.tar.gz"
splunk_s3_backup_tempdir: "/var/tmp" splunk_s3_backup_tempdir: "/var/tmp"
splunk_s3_bucket: "{{ SPLUNK_S3_BACKUPS_BUCKET }}" splunk_s3_bucket: "{{ splunk_s3_backups_bucket }}"
date: "{{ lookup('pipe', 'date +%Y-%m-%d') }}" date: "{{ lookup('pipe', 'date +%Y-%m-%dT%H%M') }}"
tasks: tasks:
- name: archive splunk configuration dir - name: archive splunk configuration dir
command: > command: tar -cpzf "{{ splunk_s3_backup_tempdir }}/{{ splunk_config_archive }}" {{ splunk_config_dir }}
tar -cpzf "{{ splunk_s3_backup_tempdir }}/{{ splunk_config_archive }}" {{ splunk_config_dir }}
- name: copy tarball to s3 bucket - name: copy tarball to s3 bucket
command: > command: aws s3 cp "{{ splunk_s3_backup_tempdir }}/{{ splunk_config_archive }}" s3://{{ splunk_s3_bucket }}
aws s3 cp "{{ splunk_s3_backup_tempdir }}/{{ splunk_config_archive }}" s3://{{ splunk_s3_bucket }}
- name: cleanup backup file - name: cleanup backup file
file: file:
path: "{{ splunk_s3_backup_tempdir }}/{{ splunk_config_archive }}" path: "{{ splunk_s3_backup_tempdir }}/{{ splunk_config_archive }}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment