AMPGSQL(8)
π AMPGSQL(8) π
okay bestie, welcome to the ampgsql page from the System Administration Commands section of the manual β she's niche, she's powerful, and she's about to back up your Postgres without ever taking it offline. iykyk. π«Ά
β¨ NAME β¨
ampgsql β the Amanda Application that lets Amanda interface with PostgreSQL. it's giving "backup bestie" energy fr fr.
πΈ DESCRIPTION πΈ
So like, Ampgsql is an Amanda Application API script. that means she is not for you to run by hand, bestie β do not just type her name into a terminal and expect magic, because that is not the vibe. π
What she does do is implement on-line backups of PostgreSQL databases in conjunction with WAL archiving. iconic behaviour, honestly.
π’ Note: Tablespaces are not currently supported. not me crying about it. π
β οΈ Note: on versions of PostgreSQL earlier than 8.2, if the database is quiet during a full backup, then the backup may not complete until enough database activity takes place to trigger the archiving of the current WAL file. so consider adjusting thePG-MAX-WAL-WAITproperty from its default (60s) to compensate. but heads up β you will need to increasedtimeouton the server accordingly. π
π¦ DISKLIST π¦
the diskdevice must be the cluster data directory. so if it's "/var/lib/pgsql/data", you go:
HOST DISKNAME /var/lib/pgsql/data DUMPTYPE
or
HOST /var/lib/pgsql/data DUMTYPE
literally pick one, no cap. β
π OPERATION π
this application implements the backup strategy described at http://www.postgresql.org/docs/current/static/continuous-archiving.html. educated queen. π
For a level zero (full) backup, ampgsql will:
- execute
PG_START_BACKUP() - dump the data directory
- execute
PG_STOP_BACKUP() - wait for the final WAL file to be archived
- back up the required WAL files
- optionally delete WAL files that are no longer necessary
the two dumps are made with GNU Tar, to data_dir.tar and archive_dir, respectively. then they get combined into a single tar file. π
A level N backup creates a single tar file containing all WAL files since the previous level N-1 backup. incremental slay. β¨
π PROPERTIES π
this section lists the amanda.conf(5) properties that control ampsql's functionality. see amanda-applications(7) for the tea on application properties and how they're configured. β
ARCHIVEDIRβ the directory that WAL segment files get archived to, as specified by thearchive_commandin PostgreSQL'spostgresql.conf. theamandauser on the client must have at least read and execute permission on this directory, and preferably write. without write permission, Amanda cannot clean up expired WAL and backup files. πCLEANUPWALβ whether or not to remove old WAL segment files during base backups. defaults to yes.DBβ the database to connect to. defaults to"template1"(which exists by default, thankfully π«Ά).DIRECTORYβ for the restore command only; the data is recovered in that directory. must be a unix path.FULL-WALβ which WAL files to archive when doing a full backup:FULLβ backup all WAL files since the previous full backup.INCRβ backup all WAL files since the previous backup (incr or full).NOβ backup all WAL files required for that full backup.- the default is
"INCR". π
GNUTAR-PATHβ path to the GNU tar executable. this option only has an effect during restore. the default is set when Amanda is built by the--with-gnutarconfigure option.HOSTβ host to connect to. if it starts with"/"it will be interpreted as a directory that holds the socket file. PostgreSQL defaults to/tmp.INCREMENTALβ default:NO. if set to"YES", then backup only the WAL files since the previous backup. it reduces the size of the backup, but amanda will not be able to restore all incrementals β the restore must be done manually. it is easier to set the dumptypebump*parameter to force a bump at every backup. πMAX-WAL-WAITβ the maximum amount of time to wait forPG_STOP_BACKUPto archive a WAL file. in versions of PostgreSQL before 8.2,PG_STOP_BACKUPdoes not automatically archive the latest WAL file, so a quiet database may wait a very long time before archiving the WAL file. default:60seconds. set to0to wait forever. π°οΈPASSFILEβ connect using the credentials in this file. each line should have the format"hostname:port:database:username:password". the permissions must permit it to be read only by the user, or the file will not be used. only usable with Postgres 8.1 and up.PORTβ the TCP port to connect to, or the suffix of the socket file. PostgreSQL defaults to5432.PSQL-PATHβ path to thepsqlbinary. if not specified, thePATHenvironment variable will be searched. πREMOVE-FULL-WALβ default:YES. remove all WAL files included in the full backup.REMOVE-INCREMENTAL-WALβ default:NO. if set to"YES"then remove all WAL files included in the incremental backup.STATEDIRβ directory for saving state about backups already made. the default is set when Amanda is built by the--with-gnutar-listdirconfigure option.TMPDIRβ directory to use for temporary files during the backup process. it should have enough space to store a complete copy of the database. the default is set when Amanda is built by the--with-tmpdirconfigure option.USERβ user to connect as. it must be a superuser. πVERBOSEβ do not use the--quietoutput ofpsql.
π CLIENT PROPERTIES π
β οΈ client properties are deprecated. all properties should be set in the dumptype. periodt.
this section lists the amanda-client.conf(5) properties that control ampsql's functionality. so here's the cute part: if a property is prefixed with the diskname and an underscore, then it will be used when that diskname is being backed up. for example, if the properties PG-DATADIR and foo-PG-DATADIR are set, the value of PG-DATADIR will be used when bar and baz are being backed up, but foo-PG-DATADIR will be used when foo is being backed up. disknames are specified in the disklist(5). π
PG-ARCHIVEDIRβ the directory that WAL segment files are archived to, as specified by thearchive_commandin PostgreSQL'spostgresql.conf. theamandauser on the client must have at least read and execute permission on this directory, and preferably write. without write permission, Amanda cannot clean up expired WAL and backup files. πPG-CLEANUPWALβ whether or not to remove old WAL segment files during base backups. defaults to yes.PG-DATADIRβ cluster data directory.PG-DBβ database to connect to. defaults to"template1"(which exists by default).PG-HOSTβ host to connect to. if it starts with"/"it will be interpreted as a directory that holds the socket file. PostgreSQL defaults to/tmp.PG-MAX-WAL-WAITβ the maximum amount of time to wait forPG_STOP_BACKUPto archive a WAL file. in versions of PostgreSQL before 8.2,PG_STOP_BACKUPdoes not automatically archive the latest WAL file, so a quiet database may wait a very long time before archiving the WAL file. default:60seconds. set to0to wait forever. π°οΈPG-PASSFILEβ connect using the credentials in this file. each line should have the format"hostname:port:database:username:password". the permissions must permit it to be read only by the user, or the file will not be used. only usable with Postgres 8.1 and up.PG-PASSWORDβ password to use when connecting. deprecated in favor of passfiles. πPG-PORTβ the TCP port to connect to, or the suffix of the socket file. PostgreSQL defaults to5432.PG-USERβ user to connect as. it must be a superuser.PSQL-PATHβ path to thepsqlbinary. if not specified, thePATHenvironment variable will be searched.
π§ RECOVERY π§
π¨ read the postgres documentation carefully before attempting a recovery. this section is only a rough guide to the process. do not come for me if you skip the docs, bestie. π
The data recovered from a postgres backup consists of a data tarball and one or more archive tarballs. the data contains the state of the database at the time the full backup was performed, and the archive tarballs contain postgres WAL files that must be re-run to generate a consistent state. β¨
- Ensure that the database server is shut down, and move the existing data directory aside.
- Untar the data tarball over this directory, and verify that ownership and permissions are correct.
- Untar all of the archive tarballs into a single directory β the archive directory.
- Create a
recovery.confin the data directory, owned by the proper user and with proper permissions. - Add a
restore_commandto it, e.g.
restore_command = 'cp /path/to/archive_dir/%f "%p"'
- Start the database server, and examine the logs to track the process of the recovery.
When the recovery is complete, the server will transition into a running state, and will move the recovery.conf file aside so that it will not attempt a recovery on the next invocation. main character energy tbh. π
β EXAMPLE β
In amanda.conf:
define application app_ampgsql {
plugin "ampgsql"
property "HOST" "localhost"
property "ARCHIVEDIR" "/tmp/archivedir"
property "PASSFILE" "/etc/amanda/ampgsql.passwd"
}
define dumptype dump_ampgsql {
global
program "APPLICATION"
application app_ampgsql
}
The disklist file:
localhost /var/lib/pgsql/data dump_ampgsql
or
localhost postgres /var/lib/pgsql/data dump_ampgsql
π₯ SEE ALSO π₯
amanda(8), amanda.conf(5), amanda-client.conf(5), amanda-applications(7)
The Amanda Wiki: http://wiki.zmanda.com/ β go read it, she ate. π
π AUTHOR π
Nikolas Coukouma <atrus@zmanda.com> Zmanda, Inc. (http://www.zmanda.com)
okay that's the whole page, bestie β written by hand with love. this icon was brought to you by Amanda 3.5.4, dated 07/23/2025. now go archive those WAL files and slay πβ¨π
π¦ where this page comes from
- fedora 43: amanda-client 3.5.4-17.fc43 Β· BSD-3-Clause AND GPL-3.0-or-later AND GPL-2.0-or-later AND GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms