copr-backend: automatic backup for log-detective.com
Fixes: https://github.com/fedora-copr/log-detective-website/issues/33
This commit is contained in:
parent
eaef753b25
commit
1a38d112c7
4 changed files with 56 additions and 0 deletions
|
@ -62,3 +62,5 @@
|
||||||
when: copr_messaging
|
when: copr_messaging
|
||||||
- role: rsnapshot-push
|
- role: rsnapshot-push
|
||||||
when: env == "production"
|
when: env == "production"
|
||||||
|
- role: log-detective-backup
|
||||||
|
when: env == "production"
|
||||||
|
|
5
roles/log-detective-backup/defaults/main.yml
Normal file
5
roles/log-detective-backup/defaults/main.yml
Normal file
|
@ -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
|
44
roles/log-detective-backup/tasks/main.yml
Normal file
44
roles/log-detective-backup/tasks/main.yml
Normal file
|
@ -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
|
5
roles/log-detective-backup/templates/backup.sh.j2
Normal file
5
roles/log-detective-backup/templates/backup.sh.j2
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
basename=$(date +%s).tar.gz
|
||||||
|
|
||||||
|
wget -O "{{ ld_backup_path }}/$basename" "{{ ld_dump_url }}"
|
Loading…
Add table
Add a link
Reference in a new issue