Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service/timer for removing old wal-e backups #144

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions shared-roles/postgresql-wal-e/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,39 @@
enabled: yes
masked: no
name: postgresql-base-backup@{{ pwe_major }}-{{ pwe_instance }}.timer

- name: systemd base backup service cleaner
register: base_backup_cleaner_service
copy:
dest: /etc/systemd/system/[email protected]
content: |
[Unit]
Description=PostgreSQL base backup cleaner

[Service]
Type=oneshot
ExecStart=/usr/bin/env bash -c 'i="%i"; i=${i/-//}; bin/envdir /etc/wal-e/%i-env.d bin/wal-e delete --confirm retain {{ pwe_retain }}'
WorkingDirectory={{ pwe_venv }}
User=postgres

- name: systemd base backup cleaner timer
register: base_backup_cleaner_timer
copy:
dest: /etc/systemd/system/[email protected]
content: |
[Unit]
Description=PostgreSQL base backup cleaner timer

[Timer]
OnCalendar=Sun 05:00

[Install]
WantedBy=timers.target

- name: systemd daemon-reload
when: base_backup_cleaner_service.changed or base_backup_cleaner_timer.changed
systemd:
daemon_reload: yes
enabled: yes
masked: no
name: postgresql-base-backup-cleaner@{{ pwe_major }}-{{ pwe_instance }}.timer
1 change: 1 addition & 0 deletions shared-roles/postgresql-wal-e/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pwe_venv: /var/lib/postgresql/wal-e
pwe_retain: 5