1AMPGSQL(8) System Administration Commands AMPGSQL(8)
2
3
4
6 ampgsql - Amanda Application to interface with PostgreSQL
7
9 Ampgsql is an Amanda Application API script. It should not be run by
10 users directly. It implements on-line backups of PostgreSQL databases
11 in conjunction with WAL archiving.
12
13 Note
14 Tablespaces are not currently supported.
15
16 Note
17 On versions of PostgreSQL earlier than 8.2, if the database is
18 quiet during a full backup, then the backup may not complete until
19 enough database activity takes place to trigger the archiving of
20 the current WAL file. Consider adjusting the PG-MAX-WAL-WAIT
21 property from its default (60s) to compensate. Note that you will
22 need to increase dtimeout on the server accordingly.
23
25 The diskdevice must be the cluster data directory, if it is
26 "/var/lib/pgsql/data":
27 HOST DISKNAME /var/lib/pgsql/data DUMPTYPE
28 or
29 HOST /var/lib/pgsql/data DUMTYPE
30
32 This application implements the backup strategy described in
33 http://www.postgresql.org/docs/current/static/continuous-archiving.html.
34 For a level zero (full) backup, ampgsql:
35
36 · execute PG_START_BACKUP()
37
38 · dump the data directory
39
40 · execute PG_STOP_BACKUP()
41
42 · wait for the final WAL file to be archived
43
44 · back up the required WAL files
45
46 · optionally delete WAL files that are no longer necessary
47
48 The two dumps are made with GNU Tar, to data_dir.tar and archive_dir,
49 respectively. They are then combined into a single tar file.
50
51 A level N backup creates a single tar file containing all WAL files
52 since the previous level N-1 backup.
53
55 This section lists the amanda.conf(5) properties that control ampsql's
56 functionality. See amanda-applications(7) for information on
57 application properties and how they are configured.
58
59 ARCHIVEDIR
60 Directory that WAL segment files are archived to, as specified by
61 the archive_command in PosgreSQL's postgresql.conf. The amanda user
62 on the client must have at least read and execute permission on
63 this directory, and preferably write. Without write permission,
64 Amanda cannot clean up expired WAL and backup files.
65
66 CLEANUPWAL
67 Whether or not to remove old WAL segment files during base backups.
68 Defaults to yes.
69
70 DB
71 Database to connect to. Defaults to "template1" (which exists by
72 default).
73
74 DIRECTORY
75 For restore command only, the data is recoved in that directory.
76 Must be a unix path.
77
78 FULL-WAL
79 Which WAL files to archive when doing a full backup.
80
81 FULL
82 Backup all WAL files since the previous full backup.
83
84 INCR
85 Backup all WAL files since the previous backup (incr or full).
86
87 NO
88 Backup all WAL files required for that full backup
89
90 The default is "INCR".
91
92 GNUTAR-PATH
93 Path to the GNU tar executable. This option only has an effect
94 during restore. The default is set when Amanda is built by the
95 --with-gnutar configure option.
96
97 HOST
98 Host to connect to. If it starts with "/" it will be interepreted
99 as a directory that holds the socket file. PostgreSQL defaults to
100 /tmp.
101
102 INCREMENTAL
103 Default: NO. If set to "YES", then backup only the WAL files since
104 the previous backup.
105
106 It reduce the size of the backup, but amanda will not be able to
107 restore all incrementals, the restore must be done manually.It is
108 easier to set the dumptype bump* parameter to force a bump at every
109 backup.
110
111 MAX-WAL-WAIT
112 The maximum amount of time to wait for PG_STOP_BACKUP to archive a
113 WAL file. In versions of PostgreSQL before 8.2, PG_STOP_BACKUP does
114 not automatically archive the latest WAL file, so a quiet database
115 may wait a very long time before archiving the WAL file. Default:
116 60 seconds. Set to 0 to wait forever.
117
118 PASSFILE
119 Connect using the creditials in this file. Each line should have
120 the format "hostname:port:database:username:password". The
121 permissions must permit it to be read only by the user, or the file
122 will not be used. Only usable with Postgres 8.1 and up.
123
124 PORT
125 The TCP port to connect to, or the suffix of the socket file.
126 PostgreSQL defaults to 5432.
127
128 PSQL-PATH
129 Path to the psql binary. If not specified, the PATH environment
130 variable will be searched.
131
132 REMOVE-FULL-WAL
133 Default: YES. Remove all WAL files included in the full backup.
134
135 REMOVE-INCREMENTAL-WAL
136 Default: NO. If set to "YES" then remove all WAL files included in
137 the incremental backup.
138
139 STATEDIR
140 Directory for saving state about backups already made. The default
141 is set when Amanda is built by the --with-gnutar-listdir configure
142 option.
143
144 TMPDIR
145 Directory to use for temporary files during the backup process. It
146 should have enough space to store a complete copy of the database.
147 The default is set when Amanda is built by the --with-tmpdir
148 configure option.
149
150 USER
151 User to connect as. It must be a superuser.
152
153 VERBOSE
154 Do not use the --quiet output of psql.
155
157 Client properties are deprecated. All properties should be set in the
158 dumptype.
159
160 This section lists the amanda-client.conf(5) properties that control
161 ampsql's functionality. If a property is prefixed with the diskname and
162 an underscore, then it will be used when that diskname is being backed
163 up. For example, if the properties PG-DATADIR and foo-PG-DATADIR are
164 set, the value of PG-DATADIR will be used when bar and baz are being
165 backed up, but foo-PG-DATADIR will be used when foo is being backed up.
166 Disknames are specified in the disklist(5).
167
168 PG-ARCHIVEDIR
169
170 Directory that WAL segment files are archived to, as specified by
171 the archive_command in PosgreSQL's postgresql.conf. The amanda
172 user on the client must have at least read and execute permission
173 on this directory, and preferably write. Without write permission,
174 Amanda cannot clean up expired WAL and backup files.
175
176 PG-CLEANUPWAL
177
178 Whether or not to remove old WAL segment files during base backups.
179 Defaults to yes.
180
181 PG-DATADIR
182
183 Cluster data directory
184
185 PG-DB
186
187 Database to connect to. Defaults to "template1" (which exists by
188 default).
189
190 PG-HOST
191
192 Host to connect to. If it starts with "/" it will be interepreted
193 as a directory that holds the socket file. PostgreSQL defaults to
194 /tmp.
195
196 PG-MAX-WAL-WAIT
197 The maximum amount of time to wait for PG_STOP_BACKUP to archive a
198 WAL file. In versions of PostgreSQL before 8.2, PG_STOP_BACKUP does
199 not automatically archive the latest WAL file, so a quiet database
200 may wait a very long time before archiving the WAL file. Default:
201 60 seconds. Set to 0 to wait forever.
202
203 PG-PASSFILE
204
205 Connect using the creditials in this file. Each line should have
206 the format "hostname:port:database:username:password". The
207 permissions must permit it to be read only by the user, or the file
208 will not be used. Only usable with Postgres 8.1 and up.
209
210 PG-PASSWORD
211
212 Password to use when connecting. Deprecated in favor of passfiles.
213
214 PG-PORT
215
216 The TCP port to connect to, or the suffix of the socket file.
217 PostgreSQL defaults to 5432.
218
219 PG-USER
220
221 User to connect as. It must be a superuser.
222
223 PSQL-PATH
224
225 Path to the psql binary. If not specified, the PATH environment
226 variable will be searched.
227
229 Read the postgres documentation carefully before attempting a recovery.
230 This section is only a rough guide to the process.
231
232 The data recovered from a postgres backup consists of a data tarball
233 and one or more archive tarballs. The data contains the state of the
234 database at the time the full backup was performed, and the archive
235 tarballs contain postgres WAL files that must be re-run to generate a
236 consistent state.
237
238 Ensure that the database server is shut down, and move the existing
239 data directory aside. Untar the data tarball over this directory, and
240 verify that ownership and permissions are correct. Untar all of the
241 archive tarballs into a single directory - the archive directory.
242 Create a recovery.conf in the data directory, owned by the proper user
243 and with proper permissions. Add a restore_command to it, e.g.,
244 restore_command = 'cp /path/to/archive_dir/%f "%p"'
245
246 Start the database server, and examine the logs to track the process of
247 the recovery. When the recovery is complete, the server will transition
248 into a running state, and will move the recovery.conf file aside so
249 that it will not attempt a recovery on the next invocation.
250
252 In amanda.conf:
253 define application app_ampgsql {
254 plugin "ampgsql"
255 property "HOST" "localhost"
256 property "ARCHIVEDIR" "/tmp/archivedir"
257 property "PASSFILE" "/etc/amanda/ampgsql.passwd"
258 }
259 define dumptype dump_ampgsql {
260 global
261 program "APPLICATION"
262 application app_ampgsql
263 }
264
265
266 The disklist file:
267 localhost /var/lib/pgsql/data dump_ampgsql
268 or
269 localhost postgres /var/lib/pgsql/data dump_ampgsql
270
272 amanda(8), amanda.conf(5), amanda-client.conf(5), amanda-
273 applications(7)
274
275 The Amanda Wiki: : http://wiki.zmanda.com/
276
278 Nikolas Coukouma <atrus@zmanda.com>
279 Zmanda, Inc. (http://www.zmanda.com)
280
281
282
283Amanda 3.5.1 12/01/2017 AMPGSQL(8)