copr-backend: automatic backup for log-detective.com

Fixes: https://github.com/fedora-copr/log-detective-website/issues/33
This commit is contained in:
Pavel Raiskup 2024-01-16 10:02:11 +01:00
parent eaef753b25
commit 1a38d112c7
4 changed files with 56 additions and 0 deletions

View File

@ -62,3 +62,5 @@
when: copr_messaging
- role: rsnapshot-push
when: env == "production"
- role: log-detective-backup
when: env == "production"

View 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

View 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

View File

@ -0,0 +1,5 @@
#! /bin/sh
basename=$(date +%s).tar.gz
wget -O "{{ ld_backup_path }}/$basename" "{{ ld_dump_url }}"