@@ -91,9 +91,21 @@ Role Variables
91
91
92
92
### Backups ###
93
93
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`.
97
109
98
110
- `postgresql_backup_local_dir`: Filesystem path on the PostgreSQL server where backup scripts will be placed.
99
111
@@ -122,9 +134,8 @@ Standard install: Default `postgresql.conf`, `pg_hba.conf` and default version f
122
134
---
123
135
124
136
- hosts: dbservers
125
- remote_user: root
126
137
roles:
127
- - postgresql
138
+ - galaxyproject. postgresql
128
139
```
129
140
130
141
Use the pgdg packages on a Debian-based host:
@@ -133,11 +144,10 @@ Use the pgdg packages on a Debian-based host:
133
144
---
134
145
135
146
- hosts : dbservers
136
- remote_user : root
137
147
vars :
138
148
postgresql_flavor : pgdg
139
149
roles :
140
- - postgresql
150
+ - galaxyproject. postgresql
141
151
` ` `
142
152
143
153
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
146
156
---
147
157
148
158
- hosts: dbservers
149
- remote_user: root
150
159
vars:
151
160
postgresql_version: 9.5
152
161
postgresql_conf:
@@ -155,18 +164,44 @@ Use the PostgreSQL 9.5 packages and set some `postgresql.conf` options and `pg_h
155
164
postgresql_pg_hba_conf:
156
165
- host all all 10.0.0.0/8 md5
157
166
roles:
158
- - postgresql
167
+ - galaxyproject. postgresql
159
168
` ` `
160
169
161
- Enable backups to /archive
170
+ Enable backups to /archive :
162
171
163
172
` ` ` yaml
164
173
- hosts: all
165
- remote_user: root
166
174
vars:
167
175
postgresql_backup_dir: /archive
168
176
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
170
205
` ` `
171
206
172
207
License
0 commit comments