pg_archivecleanup
pg_archivecleanup — clean up PostgreSQL WAL archive files
当前阅读 PG 18·选择有来源记录的版本
此版本暂无所选语言的定义,以下显示原始英文内容。
- Documented executable
- pg_archivecleanup
- Executable version
- 18.6
- Reference inventory
- Server applications
- Option definition groups
- 6
- environment
- 未知
- manual path
- pgarchivecleanup.html
- signature
- pg_archivecleanup [ option ...] archivelocation oldestkeptwalfile
- synopsis
- pg_archivecleanup [ option ...] archivelocation oldestkeptwalfile
版本定义 PG 18
pg_archivecleanup
pg_archivecleanup — clean up PostgreSQL WAL archive files
Synopsis
pg_archivecleanup [option...] archivelocation oldestkeptwalfile
Description
pg_archivecleanup is designed to be used as an archive_cleanup_command to clean up WAL file archives when running as a standby server (see Section 26.2). pg_archivecleanup can also be used as a standalone program to clean WAL file archives.
To configure a standby server to use pg_archivecleanup, put this into its postgresql.conf configuration file:
archive_cleanup_command = 'pg_archivecleanup archivelocation %r'
where archivelocation is the directory from which WAL segment files should be removed.
When used within archive_cleanup_command, all WAL files logically preceding the value of the %r argument will be removed from archivelocation. This minimizes the number of files that need to be retained, while preserving crash-restart capability. Use of this parameter is appropriate if the archivelocation is a transient staging area for this particular standby server, but not when the archivelocation is intended as a long-term WAL archive area, or when multiple standby servers are recovering from the same archive location.
When used as a standalone program all WAL files logically preceding the oldestkeptwalfile will be removed from archivelocation. In this mode, if you specify a .partial or .backup file name, then only the file prefix will be used as the oldestkeptwalfile. This treatment of .backup file name allows you to remove all WAL files archived prior to a specific base backup without error. For example, the following example will remove all files older than WAL file name 000000010000003700000010:
pg_archivecleanup -d archive 000000010000003700000010.00000020.backup pg_archivecleanup: keep WAL file "archive/000000010000003700000010" and later pg_archivecleanup: removing file "archive/00000001000000370000000F" pg_archivecleanup: removing file "archive/00000001000000370000000E"
pg_archivecleanup assumes that archivelocation is a directory readable and writable by the server-owning user.
Options
pg_archivecleanup accepts the following command-line arguments:
-b--clean-backup-history-
Remove backup history files as well. See Section 25.3.2 for details about backup history files.
-d--debug-
Print lots of debug logging output on
stderr. -n--dry-run-
Print the names of the files that would have been removed on
stdout(performs a dry run). -V--version-
Print the pg_archivecleanup version and exit.
-xextension--strip-extension=extension-
Provide an extension that will be stripped from all file names before deciding if they should be deleted. This is typically useful for cleaning up archives that have been compressed during storage, and therefore have had an extension added by the compression program. For example:
-x .gz. -?--help-
Show help about pg_archivecleanup command line arguments, and exit.
Environment
The environment variable PG_COLOR specifies whether to use color in diagnostic messages. Possible values are always, auto and never.
Notes
pg_archivecleanup is designed to work with PostgreSQL 8.0 and later when used as a standalone utility, or with PostgreSQL 9.0 and later when used as an archive cleanup command.
pg_archivecleanup is written in C and has an easy-to-modify source code, with specifically designated sections to modify for your own needs
Examples
On Linux or Unix systems, you might use:
archive_cleanup_command = 'pg_archivecleanup -d /mnt/standby/archive %r 2>>cleanup.log'
where the archive directory is physically located on the standby server, so that the archive_command is accessing it across NFS, but the files are local to the standby. This will:
-
produce debugging output in
cleanup.log -
remove no-longer-needed files from the archive directory
Documented options
| Option and arguments | Description |
|---|---|
| -b --clean-backup-history | Remove backup history files as well. See Section 25.3.2 for details about backup history files. |
| -d --debug | Print lots of debug logging output on stderr . |
| -n --dry-run | Print the names of the files that would have been removed on stdout (performs a dry run). |
| -V --version | Print the pg_archivecleanup version and exit. |
| -x extension --strip-extension= extension | Provide an extension that will be stripped from all file names before deciding if they should be deleted. This is typically useful for cleaning up archives that have been compressed during storage, and therefore have had an extension added by the compression program. For example: -x .gz . |
| -? --help | Show help about pg_archivecleanup command line arguments, and exit. |
比较版本
完整来源事实
options
map[description:Remove backup history files as well. See Section 25.3.2 for details about backup history files. names:[-b --clean-backup-history] signature:-b --clean-backup-history source_url:/docs/18/pgarchivecleanup.html summary:Remove backup history files as well. See Section 25.3.2 for details about backup history files.], map[description:Print lots of debug logging output on stderr . names:[-d --debug] signature:-d --debug source_url:/docs/18/pgarchivecleanup.html summary:Print lots of debug logging output on stderr .], map[description:Print the names of the files that would have been removed on stdout (performs a dry run). names:[-n --dry-run] signature:-n --dry-run source_url:/docs/18/pgarchivecleanup.html summary:Print the names of the files that would have been removed on stdout (performs a dry run).], map[description:Print the pg_archivecleanup version and exit. names:[-V --version] signature:-V --version source_url:/docs/18/pgarchivecleanup.html summary:Print the pg_archivecleanup version and exit.], map[description:Provide an extension that will be stripped from all file names before deciding if they should be deleted. This is typically useful for cleaning up archives that have been compressed during storage, and therefore have had an extension added by the compression program. For example: -x .gz . names:[-x extension --strip-extension= extension] signature:-x extension --strip-extension= extension source_url:/docs/18/pgarchivecleanup.html summary:Provide an extension that will be stripped from all file names before deciding if they should be deleted. This is typically useful for cleaning up archives that have been compressed during storage, and therefore have had an extension added by the compression program. For example: -x .gz .], map[description:Show help about pg_archivecleanup command line arguments, and exit. names:[-? --help] signature:-? --help source_url:/docs/18/pgarchivecleanup.html summary:Show help about pg_archivecleanup command line arguments, and exit.]
来源引用
定义来源
center · PostgreSQL 18 · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8
正文语言: en · ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8