Initial commit
Some checks failed
Ansible Playbook lint & deploy / ansible-lint (push) Successful in 12s
Ansible Playbook lint & deploy / run-ansible-mongo (push) Failing after 6s
Ansible Playbook lint & deploy / run-ansible-postgres (push) Failing after 7s

This commit is contained in:
2024-12-03 00:56:20 +00:00
commit 32d815621d
29 changed files with 465 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
[Unit]
Description=Postgres auto backup daemon
After=network.target
[Service]
Type=oneshot
User=postgres
Group=postgres
WorkingDirectory=/var/lib/postgres/
ExecStart=/usr/bin/sh -c 'pg_dumpall | xz -c -T2 > dumpall-$(date -I).xz'
ExecStart=/usr/bin/sh -c 'mcli --config-dir .mcli cp dumpall-*.xz s3/konchin-pg-backup/'
ExecStart=/usr/bin/sh -c 'rm dumpall-*.xz'
StandardError=journal
StandardOutput=journal
StandardInput=null
[Install]
WantedBy=default.target

View File

@@ -0,0 +1,8 @@
[Unit]
Description=Weekly push postgres backup to S3
[Timer]
OnCalendar=weekly Asia/Taipei
[Install]
WantedBy=timers.target

View File

@@ -0,0 +1,4 @@
---
- name: Upgrade packages
community.general.pacman:
upgrade: true

View File

@@ -0,0 +1,38 @@
---
- name: Update packages
community.general.pacman:
update_cache: true
- name: Install minio cli
community.general.pacman:
pkg:
- minio-client
notify: Upgrade packages
- name: Flush handlers
ansible.builtin.meta: flush_handlers
- name: Install postgres-backup.service
ansible.builtin.copy:
src: postgres-backup.service
dest: /etc/systemd/system/postgres-backup.service
mode: '0644'
owner: root
group: root
- name: Install postgres-backup.timer
ansible.builtin.copy:
src: postgres-backup.timer
dest: /etc/systemd/system/postgres-backup.timer
mode: '0644'
owner: root
group: root
- name: Install etc directory
ansible.builtin.file:
path: /etc/postgres-backup/
state: directory
mode: '0755'
owner: root
group: root
- name: Start and enable postgres-backup.timer
ansible.builtin.systemd_service:
name: postgres-backup.timer
state: started
enabled: true