diff --git a/playbooks/groups/copr-backend.yml b/playbooks/groups/copr-backend.yml index 99312efc90..13176dc110 100644 --- a/playbooks/groups/copr-backend.yml +++ b/playbooks/groups/copr-backend.yml @@ -62,3 +62,5 @@ when: copr_messaging - role: rsnapshot-push when: env == "production" + - role: log-detective-backup + when: env == "production" diff --git a/roles/log-detective-backup/defaults/main.yml b/roles/log-detective-backup/defaults/main.yml new file mode 100644 index 0000000000..3f08cc35e5 --- /dev/null +++ b/roles/log-detective-backup/defaults/main.yml @@ -0,0 +1,5 @@ +--- +ld_backup_user: log-detective-backups +ld_backup_path: /var/lib/copr/public_html/log-detective-backups +ld_backup_script: /usr/bin/log-detective-backup +ld_dump_url: https://log-detective.com/download diff --git a/roles/log-detective-backup/tasks/main.yml b/roles/log-detective-backup/tasks/main.yml new file mode 100644 index 0000000000..f67856b562 --- /dev/null +++ b/roles/log-detective-backup/tasks/main.yml @@ -0,0 +1,44 @@ +--- +- name: Add the user 'log-detective-backup' + ansible.builtin.user: + name: "{{ ld_backup_user }}" + comment: User used for backing-up log-detective.com + uid: 15151 + tags: + - log_detective_backup + +- name: create the log-detective.com backup directory + ansible.builtin.file: + path: "{{ ld_backup_path }}" + state: directory + owner: "{{ ld_backup_user }}" + group: "{{ ld_backup_user }}" + mode: '0700' + tags: + - log_detective_backup + +- name: install the log-detective-backup package dependencies + package: + name: + - wget + state: present + tags: + - log_detective_backup + +- name: install the backup script + template: + src: backup.sh.j2 + dest: "{{ ld_backup_script }}" + mode: '0755' + tags: + - log_detective_backup + +- name: install the cron job downloading the log-detective dumps + ansible.builtin.cron: + name: "download log-detective data dump" + minute: "0" + hour: "*" + job: "{{ ld_backup_script }}" + user: "{{ ld_backup_user }}" + tags: + - log_detective_backup diff --git a/roles/log-detective-backup/templates/backup.sh.j2 b/roles/log-detective-backup/templates/backup.sh.j2 new file mode 100644 index 0000000000..d023ee3f5d --- /dev/null +++ b/roles/log-detective-backup/templates/backup.sh.j2 @@ -0,0 +1,5 @@ +#! /bin/sh + +basename=$(date +%s).tar.gz + +wget -O "{{ ld_backup_path }}/$basename" "{{ ld_dump_url }}"