Skip to content

Commit 6453bfe

Browse files
committed
Update docs for remote backup
1 parent 625b196 commit 6453bfe

File tree

1 file changed

+47
-12
lines changed

1 file changed

+47
-12
lines changed

README.md

+47-12
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,21 @@ Role Variables
9191
9292
### Backups ###
9393
94-
- `postgresql_backup_dir`: If set, enables [PITR][postgresql_pitr] backups. Set this to a directory where your database
95-
will be backed up (this can be any format supported by rsync, e.g. `user@host:/path`). The most recent backup will be
96-
in a subdirectory named `current`.
94+
This role can deploy and schedule the configuration and scripts to maintain Postgresql [PITR][postgresql_pitr] backups.
95+
96+
Full backups will be made on the configured interval, whereas write-ahead-log (WAL) segments between full backups will
97+
be archived to `{{ postgresql_backup_dir }}/wal_archive/` when instructed by the PostgreSQL server. WAL segments can be
98+
removed from this directory once the oldest backup referencing them has been removed. This is done automatically for you
99+
by the backup script if `postgresql_backup_dir` is mounted locally.
100+
101+
When `postgresql_backup_dir` is a remote rsync path (containing a "`:`"), the backup script will still maintain backups
102+
(including deleting older full backups) but cannot prune the `wal_archive/` directory automatically. If you are able to
103+
install the standard `pg_archivecleanup` utility from the PostgreSQL client package on your backup server, you can run
104+
this role's backup script with the `--clean-archive` option directly on the backup server instead.
105+
106+
- `postgresql_backup_dir`: If set, enables PITR backups. Set this to a directory where your database will be backed up
107+
(this can be any format supported by rsync, e.g. `user@host:/path`). The most recent backup will be in a subdirectory
108+
named `current`.
97109
98110
- `postgresql_backup_local_dir`: Filesystem path on the PostgreSQL server where backup scripts will be placed.
99111
@@ -122,9 +134,8 @@ Standard install: Default `postgresql.conf`, `pg_hba.conf` and default version f
122134
---
123135
124136
- hosts: dbservers
125-
remote_user: root
126137
roles:
127-
- postgresql
138+
- galaxyproject.postgresql
128139
```
129140

130141
Use the pgdg packages on a Debian-based host:
@@ -133,11 +144,10 @@ Use the pgdg packages on a Debian-based host:
133144
---
134145

135146
- hosts: dbservers
136-
remote_user: root
137147
vars:
138148
postgresql_flavor: pgdg
139149
roles:
140-
- postgresql
150+
- galaxyproject.postgresql
141151
```
142152
143153
Use the PostgreSQL 9.5 packages and set some `postgresql.conf` options and `pg_hba.conf` entries:
@@ -146,7 +156,6 @@ Use the PostgreSQL 9.5 packages and set some `postgresql.conf` options and `pg_h
146156
---
147157
148158
- hosts: dbservers
149-
remote_user: root
150159
vars:
151160
postgresql_version: 9.5
152161
postgresql_conf:
@@ -155,18 +164,44 @@ Use the PostgreSQL 9.5 packages and set some `postgresql.conf` options and `pg_h
155164
postgresql_pg_hba_conf:
156165
- host all all 10.0.0.0/8 md5
157166
roles:
158-
- postgresql
167+
- galaxyproject.postgresql
159168
```
160169

161-
Enable backups to /archive
170+
Enable backups to /archive:
162171

163172
```yaml
164173
- hosts: all
165-
remote_user: root
166174
vars:
167175
postgresql_backup_dir: /archive
168176
roles:
169-
- postgresql
177+
- galaxyproject.postgresql
178+
```
179+
180+
Enable backups to /archive on a remote server:
181+
182+
```yaml
183+
- hosts: dbservers
184+
vars:
185+
postgresql_backup_dir: backup.example.org:/archive
186+
roles:
187+
- galaxyproject.postgresql
188+
189+
- hosts: backupservers
190+
tasks:
191+
- name: Install PostgreSQL scripts
192+
ansible.builtin.apt:
193+
name: postgresql-common
194+
- name: Copy backup script
195+
ansible.builtin.copy:
196+
src: roles/galaxyproject.postgresql/files/backup.py
197+
dest: /usr/local/bin/pgbackup.py
198+
mode: "0755"
199+
- name: Schedule WAL pruning
200+
ansible.builtin.cron:
201+
name: Prune PostgreSQL Archived WALs
202+
hour: 22
203+
minute: 0
204+
job: /usr/local/bin/pgbackup.py --clean-archive /archive
170205
```
171206

172207
License

0 commit comments

Comments
 (0)