{"Entry":{"collection":"tool","key":"pg-basebackup","name":"pg_basebackup","aliases":["pg_basebackup"],"metadata":{"aliases":["pg_basebackup"],"category":"Client applications","content_hash":"302d5a82cb86d2c4839b7b05bdcc88d2f2057edbdaadca3380e19b05448da725","imported_at":"2026-09-30T00:40:34.031926+08:00","name":"pg_basebackup","name_zh":"","slug":"pg-basebackup","summary":"pg_basebackup — take a base backup of a PostgreSQL cluster"}},"Definition":{"Collection":"tool","Key":"pg-basebackup","SourceDatabase":"center","Version":"18","SourceTable":"command_tool","SourceKey":"pg-basebackup","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","Facts":{"comparison_data":{"environment":[],"options":[{"description":"Sets the target directory to write the output to. pg_basebackup will create this directory (and any missing parent directories) if it does not exist. If it already exists, it must be empty. When the backup is in tar format, the target directory may be specified as - (dash), causing the tar file to be written to stdout . This option is required.","names":["-D directory","--pgdata= directory"],"signature":"-D directory --pgdata= directory"},{"description":"Selects the format for the output. format can be one of the following: p plain Write the output as plain files, with the same layout as the source server's data directory and tablespaces. When the cluster has no additional tablespaces, the whole database will be placed in the target directory. If the cluster contains additional tablespaces, the main data directory will be placed in the target directory, but all other tablespaces will be placed in the same absolute path as they have on the source server. (See --tablespace-mapping to change that.) This is the default format. t tar Write the output as tar files in the target directory. The main data directory's contents will be written to a file named base.tar , and each other tablespace will be written to a separate tar file named after that tablespace's OID. If the target directory is specified as - (dash), the tar contents will be written to standard output, suitable for piping to (for example) gzip . This is only allowed if the cluster has no additional tablespaces and WAL streaming is not used.","names":["-F format","--format= format"],"signature":"-F format --format= format"},{"description":"Performs an incremental backup . The backup manifest for the reference backup must be provided, and will be uploaded to the server, which will respond by sending the requested incremental backup.","names":["-i old_manifest_file","--incremental= old_manifest_file"],"signature":"-i old_manifest_file --incremental= old_manifest_file"},{"description":"Creates a standby.signal file and appends connection settings to the postgresql.auto.conf file in the target directory (or within the base archive file when using tar format). This eases setting up a standby server using the results of the backup. The postgresql.auto.conf file will record the connection settings and, if specified, the replication slot that pg_basebackup is using, so that streaming replication and logical replication slot synchronization will use the same settings later on. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable .","names":["-R","--write-recovery-conf"],"signature":"-R --write-recovery-conf"},{"description":"Instructs the server where to place the base backup. The default target is client , which specifies that the backup should be sent to the machine where pg_basebackup is running. If the target is instead set to server:/some/path , the backup will be stored on the machine where the server is running in the /some/path directory. Storing a backup on the server requires superuser privileges or having privileges of the pg_write_server_files role. If the target is set to blackhole , the contents are discarded and not stored anywhere. This should only be used for testing purposes, as you will not end up with an actual backup. Since WAL streaming is implemented by pg_basebackup rather than by the server, this option cannot be used together with -Xstream . Since that is the default, when this option is specified, you must also specify either -Xfetch or -Xnone .","names":["-t target","--target= target"],"signature":"-t target --target= target"},{"description":"Relocates the tablespace in directory olddir to newdir during the backup. To be effective, olddir must exactly match the path specification of the tablespace as it is defined on the source server. (But it is not an error if there is no tablespace in olddir on the source server.) Meanwhile newdir is a directory in the receiving host's filesystem. As with the main target directory, newdir need not exist already, but if it does exist it must be empty. Both olddir and newdir must be absolute paths. If either path needs to contain an equal sign ( = ), precede that with a backslash. This option can be specified multiple times for multiple tablespaces. If a tablespace is relocated in this way, the symbolic links inside the main data directory are updated to point to the new location. So the new data directory is ready to be used for a new server instance with all tablespaces in the updated locations. Currently, this option only works with plain output format; it is ignored if tar format is selected.","names":["-T olddir = newdir","--tablespace-mapping= olddir = newdir"],"signature":"-T olddir = newdir --tablespace-mapping= olddir = newdir"},{"description":"Sets the directory to write WAL (write-ahead log) files to. By default WAL files will be placed in the pg_wal subdirectory of the target directory, but this option can be used to place them elsewhere. waldir must be an absolute path. As with the main target directory, waldir need not exist already, but if it does exist it must be empty. This option can only be specified when the backup is in plain format.","names":["--waldir= waldir"],"signature":"--waldir= waldir"},{"description":"Includes the required WAL (write-ahead log) files in the backup. This will include all write-ahead logs generated during the backup. Unless the method none is specified, it is possible to start a postmaster in the target directory without the need to consult the WAL archive, thus making the output a completely standalone backup. The following method s for collecting the write-ahead logs are supported: n none Don't include write-ahead logs in the backup. f fetch The write-ahead log files are collected at the end of the backup. Therefore, it is necessary for the source server's wal_keep_size parameter to be set high enough that the required log data is not removed before the end of the backup. If the required log data has been recycled before it's time to transfer it, the backup will fail and be unusable. When tar format is used, the write-ahead log files will be included in the base.tar file. s stream Stream write-ahead log data while the backup is being taken. This method will open a second connection to the server and start streaming the write-ahead log in parallel while running the backup. Therefore, it will require two replication connections not just one. As long as the client can keep up with the write-ahead log data, using this method requires no extra write-ahead logs to be saved on the source server. When tar format is used, the write-ahead log files will be written to a separate file named pg_wal.tar (if the server is a version earlier than 10, the file will be named pg_xlog.tar ). This value is the default.","names":["-X method","--wal-method= method"],"signature":"-X method --wal-method= method"},{"description":"Enables gzip compression of tar file output, with the default compression level. Compression is only available when using the tar format, and the suffix .gz will automatically be added to all tar filenames.","names":["-z","--gzip"],"signature":"-z --gzip"},{"description":"Requests compression of the backup. If client or server is included, it specifies where the compression is to be performed. Compressing on the server will reduce transfer bandwidth but will increase server CPU consumption. The default is client except when --target is used. In that case, the backup is not being sent to the client, so only server compression is sensible. When -Xstream , which is the default, is used, server-side compression will not be applied to the WAL. To compress the WAL, use client-side compression, or specify -Xfetch . The compression method can be set to gzip , lz4 , zstd , none for no compression or an integer (no compression if 0, gzip if greater than 0). A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level , long , and workers . The detail string cannot be used when the compression method is specified as a plain integer. If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0, and no compression will be used if the level is 0. When the tar format is used with gzip , lz4 , or zstd , the suffix .gz , .lz4 , or .zst , respectively, will be automatically added to all tar filenames. When the plain format is used, client-side compression may not be specified, but it is still possible to request server-side compression. If this is done, the server will compress the backup for transmission, and the client will decompress and extract it. When this option is used in combination with -Xstream , pg_wal.tar will be compressed using gzip if client-side gzip compression is selected, but will not be compressed if any other compression algorithm is selected, or if server-side compression is selected.","names":["-Z level","-Z [{client|server}-] method [: detail ]","--compress= level","--compress=[{client|server}-] method [: detail ]"],"signature":"-Z level -Z [{client|server}-] method [: detail ] --compress= level --compress=[{client|server}-] method [: detail ]"},{"description":"Sets checkpoint mode to fast (immediate) or spread (the default) (see Section 25.3.4 ).","names":["-c {fast|spread}","--checkpoint={fast|spread}"],"signature":"-c {fast|spread} --checkpoint={fast|spread}"},{"description":"Specifies that the replication slot named by the --slot option should be created before starting the backup. An error is raised if the slot already exists.","names":["-C","--create-slot"],"signature":"-C --create-slot"},{"description":"Sets the label for the backup. If none is specified, a default value of “ pg_basebackup base backup ” will be used.","names":["-l label","--label= label"],"signature":"-l label --label= label"},{"description":"By default, when pg_basebackup aborts with an error, it removes any directories it might have created before discovering that it cannot finish the job (for example, the target directory and write-ahead log directory). This option inhibits tidying-up and is thus useful for debugging. Note that tablespace directories are not cleaned up either way.","names":["-n","--no-clean"],"signature":"-n --no-clean"},{"description":"By default, pg_basebackup will wait for all files to be written safely to disk. This option causes pg_basebackup to return without waiting, which is faster, but means that a subsequent operating system crash can leave the base backup corrupt. Generally, this option is useful for testing but should not be used when creating a production installation.","names":["-N","--no-sync"],"signature":"-N --no-sync"},{"description":"Enables progress reporting. Turning this on will deliver an approximate progress report during the backup. Since the database may change during the backup, this is only an approximation and may not end at exactly 100% . In particular, when WAL log is included in the backup, the total amount of data cannot be estimated in advance, and in this case the estimated target size will increase once it passes the total estimate without WAL.","names":["-P","--progress"],"signature":"-P --progress"},{"description":"Sets the maximum transfer rate at which data is collected from the source server. This can be useful to limit the impact of pg_basebackup on the server. Values are in kilobytes per second. Use a suffix of M to indicate megabytes per second. A suffix of k is also accepted, and has no effect. Valid values are between 32 kilobytes per second and 1024 megabytes per second. This option always affects transfer of the data directory. Transfer of WAL files is only affected if the collection method is fetch .","names":["-r rate","--max-rate= rate"],"signature":"-r rate --max-rate= rate"},{"description":"This option can only be used together with -X stream . It causes WAL streaming to use the specified replication slot. If the base backup is intended to be used as a streaming-replication standby using a replication slot, the standby should then use the same replication slot name as primary_slot_name . This ensures that the primary server does not remove any necessary WAL data in the time between the end of the base backup and the start of streaming replication on the new standby. The specified replication slot has to exist unless the option -C is also used. If this option is not specified and the server supports temporary replication slots (version 10 and later), then a temporary replication slot is automatically used for WAL streaming.","names":["-S slotname","--slot= slotname"],"signature":"-S slotname --slot= slotname"},{"description":"When set to fsync , which is the default, pg_basebackup will recursively open and synchronize all files in the backup directory. When the plain format is used, the search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the backup directory. When the plain format is used, pg_basebackup will also synchronize the file systems that contain the WAL files and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used.","names":["--sync-method= method"],"signature":"--sync-method= method"},{"description":"Enables verbose mode. Will output some extra steps during startup and shutdown, as well as show the exact file name that is currently being processed if progress reporting is also enabled.","names":["-v","--verbose"],"signature":"-v --verbose"},{"description":"Specifies the checksum algorithm that should be applied to each file included in the backup manifest. Currently, the available algorithms are NONE , CRC32C , SHA224 , SHA256 , SHA384 , and SHA512 . The default is CRC32C . If NONE is selected, the backup manifest will not contain any checksums. Otherwise, it will contain a checksum of each file in the backup using the specified algorithm. In addition, the manifest will always contain a SHA256 checksum of its own contents. The SHA algorithms are significantly more CPU-intensive than CRC32C , so selecting one of them may increase the time required to complete the backup. Using a SHA hash function provides a cryptographically secure digest of each file for users who wish to verify that the backup has not been tampered with, while the CRC-32C algorithm provides a checksum that is much faster to calculate; it is good at catching errors due to accidental changes but is not resistant to malicious modifications. Note that, to be useful against an adversary who has access to the backup, the backup manifest would need to be stored securely elsewhere or otherwise verified not to have been modified since the backup was taken. pg_verifybackup can be used to check the integrity of a backup against the backup manifest.","names":["--manifest-checksums= algorithm"],"signature":"--manifest-checksums= algorithm"},{"description":"Forces all filenames in the backup manifest to be hex-encoded. If this option is not specified, only non-UTF8 filenames are hex-encoded. This option is mostly intended to test that tools which read a backup manifest file properly handle this case.","names":["--manifest-force-encode"],"signature":"--manifest-force-encode"},{"description":"Prevents the server from estimating the total amount of backup data that will be streamed, resulting in the backup_total column in the pg_stat_progress_basebackup view always being NULL . Without this option, the backup will start by enumerating the size of the entire database, and then go back and send the actual contents. This may make the backup take slightly longer, and in particular it will take longer before the first data is sent. This option is useful to avoid such estimation time if it's too long. This option is not allowed when using --progress .","names":["--no-estimate-size"],"signature":"--no-estimate-size"},{"description":"Disables generation of a backup manifest. If this option is not specified, the server will generate and send a backup manifest which can be verified using pg_verifybackup . The manifest is a list of every file present in the backup with the exception of any WAL files that may be included. It also stores the size, last modification time, and an optional checksum for each file.","names":["--no-manifest"],"signature":"--no-manifest"},{"description":"Prevents the creation of a temporary replication slot for the backup. By default, if log streaming is selected but no slot name is given with the -S option, then a temporary replication slot is created (if supported by the source server). The main purpose of this option is to allow taking a base backup when the server has no free replication slots. Using a replication slot is almost always preferred, because it prevents needed WAL from being removed by the server during the backup.","names":["--no-slot"],"signature":"--no-slot"},{"description":"Disables verification of checksums, if they are enabled on the server the base backup is taken from. By default, checksums are verified and checksum failures will result in a non-zero exit status. However, the base backup will not be removed in such a case, as if the --no-clean option had been used. Checksum verification failures will also be reported in the pg_stat_database view.","names":["--no-verify-checksums"],"signature":"--no-verify-checksums"},{"description":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options. This option is called --dbname for consistency with other client applications, but because pg_basebackup doesn't connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name ( replication ) for purposes of looking up the replication connection's password in ~/.pgpass . Similarly, middleware or proxies used in connecting to PostgreSQL might utilize the name for purposes such as connection routing. The database name can also be used by logical replication slot synchronization .","names":["-d connstr","--dbname= connstr"],"signature":"-d connstr --dbname= connstr"},{"description":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for a Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted.","names":["-h host","--host= host"],"signature":"-h host --host= host"},{"description":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default.","names":["-p port","--port= port"],"signature":"-p port --port= port"},{"description":"Specifies the number of seconds between status packets sent back to the source server. Smaller values allow more accurate monitoring of backup progress from the server. A value of zero disables periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout-based disconnects. The default value is 10 seconds.","names":["-s interval","--status-interval= interval"],"signature":"-s interval --status-interval= interval"},{"description":"Specifies the user name to connect as.","names":["-U username","--username= username"],"signature":"-U username --username= username"},{"description":"Prevents issuing a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.","names":["-w","--no-password"],"signature":"-w --no-password"},{"description":"Forces pg_basebackup to prompt for a password before connecting to the source server. This option is never essential, since pg_basebackup will automatically prompt for a password if the server demands password authentication. However, pg_basebackup will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt.","names":["-W","--password"],"signature":"-W --password"},{"description":"Prints the pg_basebackup version and exits.","names":["-V","--version"],"signature":"-V --version"},{"description":"Shows help about pg_basebackup command line arguments, and exits.","names":["-?","--help"],"signature":"-? --help"}],"synopsis":["pg_basebackup [ option ...]"]},"comparison_hash":"1355c21a25dc07b130a2e139c0430698018dbc37b620dff3f0f565fbaec56228","description":["pg_basebackup — take a base backup of a PostgreSQL cluster"],"environment":[],"facts":[{"label":"Documented executable","value":"pg_basebackup"},{"label":"Executable version","value":"18.6"},{"label":"Reference inventory","value":"Client applications"},{"label":"Option definition groups","value":"35"}],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PGBASEBACKUP\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_basebackup — take a base backup of a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e cluster\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.10.4.1\"\u003e\u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e is used to take a base backup of a running \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster. The backup is taken without affecting other clients of the database, and can be used both for point-in-time recovery (see \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html\" title=\"25.3. Continuous Archiving and Point-in-Time Recovery (PITR)\"\u003eSection 25.3\u003c/a\u003e) and as the starting point for a log-shipping or streaming-replication standby server (see \u003ca class=\"xref\" href=\"/docs/18/warm-standby.html\" title=\"26.2. Log-Shipping Standby Servers\"\u003eSection 26.2\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e can take a full or incremental base backup of the database. When used to take a full backup, it makes an exact copy of the database cluster's files. When used to take an incremental backup, some files that would have been part of a full backup may be replaced with incremental versions of the same files, containing only those blocks that have been modified since the reference backup. An incremental backup cannot be used directly; instead, \u003ca class=\"xref\" href=\"/docs/18/app-pgcombinebackup.html\" title=\"pg_combinebackup\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_combinebackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e must first be used to combine it with the previous backups upon which it depends. See \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html#BACKUP-INCREMENTAL-BACKUP\" title=\"25.3.3. Making an Incremental Backup\"\u003eSection 25.3.3\u003c/a\u003e for more information about incremental backups, and \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html#BACKUP-PITR-RECOVERY\" title=\"25.3.5. Recovering Using a Continuous Archive Backup\"\u003eSection 25.3.5\u003c/a\u003e for steps to recover from a backup.\u003c/p\u003e\n\u003cp\u003eIn any mode, \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e makes sure the server is put into and out of backup mode automatically. Backups are always taken of the entire database cluster; it is not possible to back up individual databases or database objects. For selective backups, another tool such as \u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e must be used.\u003c/p\u003e\n\u003cp\u003eThe backup is made over a regular \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e connection that uses the replication protocol. The connection must be made with a user ID that has \u003ccode class=\"literal\"\u003eREPLICATION\u003c/code\u003e permissions (see \u003ca class=\"xref\" href=\"/docs/18/role-attributes.html\" title=\"21.2. Role Attributes\"\u003eSection 21.2\u003c/a\u003e) or is a superuser, and \u003ca class=\"link\" href=\"/docs/18/auth-pg-hba-conf.html\" title=\"20.1. The pg_hba.conf File\"\u003e\u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e\u003c/a\u003e must permit the replication connection. The server must also be configured with \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-MAX-WAL-SENDERS\"\u003emax_wal_senders\u003c/a\u003e set high enough to provide at least one walsender for the backup plus one for WAL streaming (if used).\u003c/p\u003e\n\u003cp\u003eThere can be multiple \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003es running at the same time, but it is usually better from a performance point of view to take only one backup, and copy the result.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e can make a base backup from not only a primary server but also a standby. To take a backup from a standby, set up the standby so that it can accept replication connections (that is, set \u003ccode class=\"varname\"\u003emax_wal_senders\u003c/code\u003e and \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-HOT-STANDBY\"\u003ehot_standby\u003c/a\u003e, and configure its \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e appropriately). You will also need to enable \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\"\u003efull_page_writes\u003c/a\u003e on the primary.\u003c/p\u003e\n\u003cp\u003eNote that there are some limitations in taking a backup from a standby:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eThe backup history file is not created in the database cluster backed up.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e cannot force the standby to switch to a new WAL file at the end of backup. When you are using \u003ccode class=\"literal\"\u003e-X none\u003c/code\u003e, if write activity on the primary is low, \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e may need to wait a long time for the last WAL file required for the backup to be switched and archived. In this case, it may be useful to run \u003ccode class=\"function\"\u003epg_switch_wal\u003c/code\u003e on the primary in order to trigger an immediate WAL file switch.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf the standby is promoted to be primary during backup, the backup fails.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eAll WAL records required for the backup must contain sufficient full-page writes, which requires you to enable \u003ccode class=\"varname\"\u003efull_page_writes\u003c/code\u003e on the primary.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eWhenever \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e is taking a base backup, the server's \u003ccode class=\"structname\"\u003epg_stat_progress_basebackup\u003c/code\u003e view will report the progress of the backup. See \u003ca class=\"xref\" href=\"/docs/18/progress-reporting.html#BASEBACKUP-PROGRESS-REPORTING\" title=\"27.4.6. Base Backup Progress Reporting\"\u003eSection 27.4.6\u003c/a\u003e for details.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cp\u003eThe following command-line options control the location and format of the output:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the target directory to write the output to. \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will create this directory (and any missing parent directories) if it does not exist. If it already exists, it must be empty.\u003c/p\u003e\n\u003cp\u003eWhen the backup is in tar format, the target directory may be specified as \u003ccode class=\"literal\"\u003e-\u003c/code\u003e (dash), causing the tar file to be written to \u003ccode class=\"literal\"\u003estdout\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option is required.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F \u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--format=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSelects the format for the output. \u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e can be one of the following:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ep\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eplain\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite the output as plain files, with the same layout as the source server's data directory and tablespaces. When the cluster has no additional tablespaces, the whole database will be placed in the target directory. If the cluster contains additional tablespaces, the main data directory will be placed in the target directory, but all other tablespaces will be placed in the same absolute path as they have on the source server. (See \u003ccode class=\"option\"\u003e--tablespace-mapping\u003c/code\u003e to change that.)\u003c/p\u003e\n\u003cp\u003eThis is the default format.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003et\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etar\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite the output as tar files in the target directory. The main data directory's contents will be written to a file named \u003ccode class=\"filename\"\u003ebase.tar\u003c/code\u003e, and each other tablespace will be written to a separate tar file named after that tablespace's OID.\u003c/p\u003e\n\u003cp\u003eIf the target directory is specified as \u003ccode class=\"literal\"\u003e-\u003c/code\u003e (dash), the tar contents will be written to standard output, suitable for piping to (for example) \u003cspan class=\"productname\"\u003egzip\u003c/span\u003e. This is only allowed if the cluster has no additional tablespaces and WAL streaming is not used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-i \u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_manifest_file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--incremental=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_manifest_file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerforms an \u003ca class=\"link\" href=\"/docs/18/continuous-archiving.html#BACKUP-INCREMENTAL-BACKUP\" title=\"25.3.3. Making an Incremental Backup\"\u003eincremental backup\u003c/a\u003e. The backup manifest for the reference backup must be provided, and will be uploaded to the server, which will respond by sending the requested incremental backup.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--write-recovery-conf\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreates a \u003ca class=\"link\" href=\"/docs/18/warm-standby.html#FILE-STANDBY-SIGNAL\"\u003e\u003ccode class=\"filename\"\u003estandby.signal\u003c/code\u003e\u003c/a\u003e  file and appends connection settings to the \u003ccode class=\"filename\"\u003epostgresql.auto.conf\u003c/code\u003e file in the target directory (or within the base archive file when using tar format). This eases setting up a standby server using the results of the backup.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"filename\"\u003epostgresql.auto.conf\u003c/code\u003e file will record the connection settings and, if specified, the replication slot that \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e is using, so that streaming replication and \u003ca class=\"link\" href=\"/docs/18/logicaldecoding-explanation.html#LOGICALDECODING-REPLICATION-SLOTS-SYNCHRONIZATION\" title=\"47.2.3. Replication Slot Synchronization\"\u003elogical replication slot synchronization\u003c/a\u003e will use the same settings later on. The dbname will be recorded only if the dbname was specified explicitly in the connection string or \u003ca class=\"link\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eenvironment variable\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t \u003cem class=\"replaceable\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--target=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eInstructs the server where to place the base backup. The default target is \u003ccode class=\"literal\"\u003eclient\u003c/code\u003e, which specifies that the backup should be sent to the machine where \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e is running. If the target is instead set to \u003ccode class=\"literal\"\u003eserver:/some/path\u003c/code\u003e, the backup will be stored on the machine where the server is running in the \u003ccode class=\"literal\"\u003e/some/path\u003c/code\u003e directory. Storing a backup on the server requires superuser privileges or having privileges of the \u003ccode class=\"literal\"\u003epg_write_server_files\u003c/code\u003e role. If the target is set to \u003ccode class=\"literal\"\u003eblackhole\u003c/code\u003e, the contents are discarded and not stored anywhere. This should only be used for testing purposes, as you will not end up with an actual backup.\u003c/p\u003e\n\u003cp\u003eSince WAL streaming is implemented by \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e rather than by the server, this option cannot be used together with \u003ccode class=\"literal\"\u003e-Xstream\u003c/code\u003e. Since that is the default, when this option is specified, you must also specify either \u003ccode class=\"literal\"\u003e-Xfetch\u003c/code\u003e or \u003ccode class=\"literal\"\u003e-Xnone\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--tablespace-mapping=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRelocates the tablespace in directory \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e during the backup. To be effective, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e must exactly match the path specification of the tablespace as it is defined on the source server. (But it is not an error if there is no tablespace in \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e on the source server.) Meanwhile \u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e is a directory in the receiving host's filesystem. As with the main target directory, \u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e need not exist already, but if it does exist it must be empty. Both \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e must be absolute paths. If either path needs to contain an equal sign (\u003ccode class=\"literal\"\u003e=\u003c/code\u003e), precede that with a backslash. This option can be specified multiple times for multiple tablespaces.\u003c/p\u003e\n\u003cp\u003eIf a tablespace is relocated in this way, the symbolic links inside the main data directory are updated to point to the new location. So the new data directory is ready to be used for a new server instance with all tablespaces in the updated locations.\u003c/p\u003e\n\u003cp\u003eCurrently, this option only works with plain output format; it is ignored if tar format is selected.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--waldir=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ewaldir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the directory to write WAL (write-ahead log) files to. By default WAL files will be placed in the \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e subdirectory of the target directory, but this option can be used to place them elsewhere. \u003cem class=\"replaceable\"\u003e\u003ccode\u003ewaldir\u003c/code\u003e\u003c/em\u003e must be an absolute path. As with the main target directory, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ewaldir\u003c/code\u003e\u003c/em\u003e need not exist already, but if it does exist it must be empty. This option can only be specified when the backup is in plain format.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-X \u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wal-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIncludes the required WAL (write-ahead log) files in the backup. This will include all write-ahead logs generated during the backup. Unless the method \u003ccode class=\"literal\"\u003enone\u003c/code\u003e is specified, it is possible to start a postmaster in the target directory without the need to consult the WAL archive, thus making the output a completely standalone backup.\u003c/p\u003e\n\u003cp\u003eThe following \u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003es for collecting the write-ahead logs are supported:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003en\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003enone\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDon't include write-ahead logs in the backup.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ef\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efetch\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe write-ahead log files are collected at the end of the backup. Therefore, it is necessary for the source server's \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-WAL-KEEP-SIZE\"\u003ewal_keep_size\u003c/a\u003e parameter to be set high enough that the required log data is not removed before the end of the backup. If the required log data has been recycled before it's time to transfer it, the backup will fail and be unusable.\u003c/p\u003e\n\u003cp\u003eWhen tar format is used, the write-ahead log files will be included in the \u003ccode class=\"filename\"\u003ebase.tar\u003c/code\u003e file.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003es\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003estream\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eStream write-ahead log data while the backup is being taken. This method will open a second connection to the server and start streaming the write-ahead log in parallel while running the backup. Therefore, it will require two replication connections not just one. As long as the client can keep up with the write-ahead log data, using this method requires no extra write-ahead logs to be saved on the source server.\u003c/p\u003e\n\u003cp\u003eWhen tar format is used, the write-ahead log files will be written to a separate file named \u003ccode class=\"filename\"\u003epg_wal.tar\u003c/code\u003e (if the server is a version earlier than 10, the file will be named \u003ccode class=\"filename\"\u003epg_xlog.tar\u003c/code\u003e).\u003c/p\u003e\n\u003cp\u003eThis value is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-z\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--gzip\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables gzip compression of tar file output, with the default compression level. Compression is only available when using the tar format, and the suffix \u003ccode class=\"filename\"\u003e.gz\u003c/code\u003e will automatically be added to all tar filenames.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-Z \u003cem class=\"replaceable\"\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-Z [{client|server}-]\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem class=\"replaceable\"\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--compress=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--compress=[{client|server}-]\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem class=\"replaceable\"\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequests compression of the backup. If \u003ccode class=\"literal\"\u003eclient\u003c/code\u003e or \u003ccode class=\"literal\"\u003eserver\u003c/code\u003e is included, it specifies where the compression is to be performed. Compressing on the server will reduce transfer bandwidth but will increase server CPU consumption. The default is \u003ccode class=\"literal\"\u003eclient\u003c/code\u003e except when \u003ccode class=\"literal\"\u003e--target\u003c/code\u003e is used. In that case, the backup is not being sent to the client, so only server compression is sensible. When \u003ccode class=\"literal\"\u003e-Xstream\u003c/code\u003e, which is the default, is used, server-side compression will not be applied to the WAL. To compress the WAL, use client-side compression, or specify \u003ccode class=\"literal\"\u003e-Xfetch\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe compression method can be set to \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e, \u003ccode class=\"literal\"\u003elz4\u003c/code\u003e, \u003ccode class=\"literal\"\u003ezstd\u003c/code\u003e, \u003ccode class=\"literal\"\u003enone\u003c/code\u003e for no compression or an integer (no compression if 0, \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e if greater than 0). A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword\u003c/code\u003e\u003c/em\u003e or \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword=value\u003c/code\u003e\u003c/em\u003e. Currently, the supported keywords are \u003ccode class=\"literal\"\u003elevel\u003c/code\u003e, \u003ccode class=\"literal\"\u003elong\u003c/code\u003e, and \u003ccode class=\"literal\"\u003eworkers\u003c/code\u003e. The detail string cannot be used when the compression method is specified as a plain integer.\u003c/p\u003e\n\u003cp\u003eIf no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e compression will be used if the level is greater than 0, and no compression will be used if the level is 0.\u003c/p\u003e\n\u003cp\u003eWhen the tar format is used with \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e, \u003ccode class=\"literal\"\u003elz4\u003c/code\u003e, or \u003ccode class=\"literal\"\u003ezstd\u003c/code\u003e, the suffix \u003ccode class=\"filename\"\u003e.gz\u003c/code\u003e, \u003ccode class=\"filename\"\u003e.lz4\u003c/code\u003e, or \u003ccode class=\"filename\"\u003e.zst\u003c/code\u003e, respectively, will be automatically added to all tar filenames. When the plain format is used, client-side compression may not be specified, but it is still possible to request server-side compression. If this is done, the server will compress the backup for transmission, and the client will decompress and extract it.\u003c/p\u003e\n\u003cp\u003eWhen this option is used in combination with \u003ccode class=\"literal\"\u003e-Xstream\u003c/code\u003e, \u003ccode class=\"literal\"\u003epg_wal.tar\u003c/code\u003e will be compressed using \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e if client-side gzip compression is selected, but will not be compressed if any other compression algorithm is selected, or if server-side compression is selected.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following command-line options control the generation of the backup and the invocation of the program:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c {fast|spread}\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--checkpoint={fast|spread}\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets checkpoint mode to fast (immediate) or spread (the default) (see \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.4. Making a Base Backup Using the Low Level API\"\u003eSection 25.3.4\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-C\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--create-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies that the replication slot named by the \u003ccode class=\"literal\"\u003e--slot\u003c/code\u003e option should be created before starting the backup. An error is raised if the slot already exists.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l \u003cem class=\"replaceable\"\u003e\u003ccode\u003elabel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--label=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elabel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the label for the backup. If none is specified, a default value of \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e\u003ccode class=\"literal\"\u003epg_basebackup base backup\u003c/code\u003e\u003c/span\u003e”\u003c/span\u003e will be used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-clean\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, when \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e aborts with an error, it removes any directories it might have created before discovering that it cannot finish the job (for example, the target directory and write-ahead log directory). This option inhibits tidying-up and is thus useful for debugging.\u003c/p\u003e\n\u003cp\u003eNote that tablespace directories are not cleaned up either way.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e will wait for all files to be written safely to disk. This option causes \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e to return without waiting, which is faster, but means that a subsequent operating system crash can leave the base backup corrupt. Generally, this option is useful for testing but should not be used when creating a production installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--progress\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables progress reporting. Turning this on will deliver an approximate progress report during the backup. Since the database may change during the backup, this is only an approximation and may not end at exactly \u003ccode class=\"literal\"\u003e100%\u003c/code\u003e. In particular, when WAL log is included in the backup, the total amount of data cannot be estimated in advance, and in this case the estimated target size will increase once it passes the total estimate without WAL.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-r \u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--max-rate=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the maximum transfer rate at which data is collected from the source server. This can be useful to limit the impact of \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e on the server. Values are in kilobytes per second. Use a suffix of \u003ccode class=\"literal\"\u003eM\u003c/code\u003e to indicate megabytes per second. A suffix of \u003ccode class=\"literal\"\u003ek\u003c/code\u003e is also accepted, and has no effect. Valid values are between 32 kilobytes per second and 1024 megabytes per second.\u003c/p\u003e\n\u003cp\u003eThis option always affects transfer of the data directory. Transfer of WAL files is only affected if the collection method is \u003ccode class=\"literal\"\u003efetch\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S \u003cem class=\"replaceable\"\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--slot=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option can only be used together with \u003ccode class=\"literal\"\u003e-X stream\u003c/code\u003e. It causes WAL streaming to use the specified replication slot. If the base backup is intended to be used as a streaming-replication standby using a replication slot, the standby should then use the same replication slot name as \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-PRIMARY-SLOT-NAME\"\u003eprimary_slot_name\u003c/a\u003e. This ensures that the primary server does not remove any necessary WAL data in the time between the end of the base backup and the start of streaming replication on the new standby.\u003c/p\u003e\n\u003cp\u003eThe specified replication slot has to exist unless the option \u003ccode class=\"option\"\u003e-C\u003c/code\u003e is also used.\u003c/p\u003e\n\u003cp\u003eIf this option is not specified and the server supports temporary replication slots (version 10 and later), then a temporary replication slot is automatically used for WAL streaming.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sync-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen set to \u003ccode class=\"literal\"\u003efsync\u003c/code\u003e, which is the default, \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e will recursively open and synchronize all files in the backup directory. When the plain format is used, the search for files will follow symbolic links for the WAL directory and each configured tablespace.\u003c/p\u003e\n\u003cp\u003eOn Linux, \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e may be used instead to ask the operating system to synchronize the whole file system that contains the backup directory. When the plain format is used, \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e will also synchronize the file systems that contain the WAL files and each tablespace. See \u003ca class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\"\u003erecovery_init_sync_method\u003c/a\u003e for information about the caveats to be aware of when using \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option has no effect when \u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables verbose mode. Will output some extra steps during startup and shutdown, as well as show the exact file name that is currently being processed if progress reporting is also enabled.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--manifest-checksums=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ealgorithm\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the checksum algorithm that should be applied to each file included in the backup manifest. Currently, the available algorithms are \u003ccode class=\"literal\"\u003eNONE\u003c/code\u003e, \u003ccode class=\"literal\"\u003eCRC32C\u003c/code\u003e, \u003ccode class=\"literal\"\u003eSHA224\u003c/code\u003e, \u003ccode class=\"literal\"\u003eSHA256\u003c/code\u003e, \u003ccode class=\"literal\"\u003eSHA384\u003c/code\u003e, and \u003ccode class=\"literal\"\u003eSHA512\u003c/code\u003e. The default is \u003ccode class=\"literal\"\u003eCRC32C\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003eNONE\u003c/code\u003e is selected, the backup manifest will not contain any checksums. Otherwise, it will contain a checksum of each file in the backup using the specified algorithm. In addition, the manifest will always contain a \u003ccode class=\"literal\"\u003eSHA256\u003c/code\u003e checksum of its own contents. The \u003ccode class=\"literal\"\u003eSHA\u003c/code\u003e algorithms are significantly more CPU-intensive than \u003ccode class=\"literal\"\u003eCRC32C\u003c/code\u003e, so selecting one of them may increase the time required to complete the backup.\u003c/p\u003e\n\u003cp\u003eUsing a SHA hash function provides a cryptographically secure digest of each file for users who wish to verify that the backup has not been tampered with, while the CRC-32C algorithm provides a checksum that is much faster to calculate; it is good at catching errors due to accidental changes but is not resistant to malicious modifications. Note that, to be useful against an adversary who has access to the backup, the backup manifest would need to be stored securely elsewhere or otherwise verified not to have been modified since the backup was taken.\u003c/p\u003e\n\u003cp\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgverifybackup.html\" title=\"pg_verifybackup\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_verifybackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e can be used to check the integrity of a backup against the backup manifest.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--manifest-force-encode\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForces all filenames in the backup manifest to be hex-encoded. If this option is not specified, only non-UTF8 filenames are hex-encoded. This option is mostly intended to test that tools which read a backup manifest file properly handle this case.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-estimate-size\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrevents the server from estimating the total amount of backup data that will be streamed, resulting in the \u003ccode class=\"structfield\"\u003ebackup_total\u003c/code\u003e column in the \u003ccode class=\"structname\"\u003epg_stat_progress_basebackup\u003c/code\u003e view always being \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWithout this option, the backup will start by enumerating the size of the entire database, and then go back and send the actual contents. This may make the backup take slightly longer, and in particular it will take longer before the first data is sent. This option is useful to avoid such estimation time if it's too long.\u003c/p\u003e\n\u003cp\u003eThis option is not allowed when using \u003ccode class=\"option\"\u003e--progress\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-manifest\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDisables generation of a backup manifest. If this option is not specified, the server will generate and send a backup manifest which can be verified using \u003ca class=\"xref\" href=\"/docs/18/app-pgverifybackup.html\" title=\"pg_verifybackup\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_verifybackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e. The manifest is a list of every file present in the backup with the exception of any WAL files that may be included. It also stores the size, last modification time, and an optional checksum for each file.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrevents the creation of a temporary replication slot for the backup.\u003c/p\u003e\n\u003cp\u003eBy default, if log streaming is selected but no slot name is given with the \u003ccode class=\"option\"\u003e-S\u003c/code\u003e option, then a temporary replication slot is created (if supported by the source server).\u003c/p\u003e\n\u003cp\u003eThe main purpose of this option is to allow taking a base backup when the server has no free replication slots. Using a replication slot is almost always preferred, because it prevents needed WAL from being removed by the server during the backup.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-verify-checksums\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDisables verification of checksums, if they are enabled on the server the base backup is taken from.\u003c/p\u003e\n\u003cp\u003eBy default, checksums are verified and checksum failures will result in a non-zero exit status. However, the base backup will not be removed in such a case, as if the \u003ccode class=\"option\"\u003e--no-clean\u003c/code\u003e option had been used. Checksum verification failures will also be reported in the \u003ca class=\"link\" href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW\" title=\"27.2.17. pg_stat_database\"\u003e\u003ccode class=\"structname\"\u003epg_stat_database\u003c/code\u003e\u003c/a\u003e view.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following command-line options control the connection to the source server:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d \u003cem class=\"replaceable\"\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dbname=\u003cem class=\"replaceable\"\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies parameters used to connect to the server, as a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e; these will override any conflicting command line options.\u003c/p\u003e\n\u003cp\u003eThis option is called \u003ccode class=\"literal\"\u003e--dbname\u003c/code\u003e for consistency with other client applications, but because \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e doesn't connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name (\u003ccode class=\"literal\"\u003ereplication\u003c/code\u003e) for purposes of looking up the replication connection's password in \u003ccode class=\"filename\"\u003e~/.pgpass\u003c/code\u003e. Similarly, middleware or proxies used in connecting to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e might utilize the name for purposes such as connection routing. The database name can also be used by \u003ca class=\"link\" href=\"/docs/18/logicaldecoding-explanation.html#LOGICALDECODING-REPLICATION-SLOTS-SYNCHRONIZATION\" title=\"47.2.3. Replication Slot Synchronization\"\u003elogical replication slot synchronization\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for a Unix domain socket. The default is taken from the \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e environment variable, if set, else a Unix domain socket connection is attempted.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable, if set, or a compiled-in default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s \u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--status-interval=\u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the number of seconds between status packets sent back to the source server. Smaller values allow more accurate monitoring of backup progress from the server. A value of zero disables periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout-based disconnects. The default value is 10 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the user name to connect as.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrevents issuing a password prompt. If the server requires password authentication and a password is not available by other means such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForces \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e to prompt for a password before connecting to the source server.\u003c/p\u003e\n\u003cp\u003eThis option is never essential, since \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will automatically prompt for a password if the server demands password authentication. However, \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther options are also available:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrints the \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e version and exits.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows help about \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e command line arguments, and exits.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eThe environment variable \u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e specifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.8\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eAt the beginning of the backup, a checkpoint needs to be performed on the source server. This can take some time (especially if the option \u003ccode class=\"literal\"\u003e--checkpoint=fast\u003c/code\u003e is not used), during which \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will appear to be idle.\u003c/p\u003e\n\u003cp\u003eThe backup will include all files in the data directory and tablespaces, including the configuration files and any additional files placed in the directory by third parties, except certain temporary files managed by PostgreSQL and operating system files. But only regular files and directories are copied, except that symbolic links used for tablespaces are preserved. Symbolic links pointing to certain directories known to PostgreSQL are copied as empty directories. Other symbolic links and special device files are skipped. See \u003ca class=\"xref\" href=\"/docs/18/protocol-replication.html\" title=\"54.4. Streaming Replication Protocol\"\u003eSection 54.4\u003c/a\u003e for the precise details.\u003c/p\u003e\n\u003cp\u003eIn plain format, tablespaces will be backed up to the same path they have on the source server, unless the option \u003ccode class=\"literal\"\u003e--tablespace-mapping\u003c/code\u003e is used. Without this option, running a plain format base backup on the same host as the server will not work if tablespaces are in use, because the backup would have to be written to the same directory locations as the original tablespaces.\u003c/p\u003e\n\u003cp\u003eWhen tar format is used, it is the user's responsibility to unpack each tar file before starting a PostgreSQL server that uses the data. If there are additional tablespaces, the tar files for them need to be unpacked in the correct locations. In this case the symbolic links for those tablespaces will be created by the server according to the contents of the \u003ccode class=\"filename\"\u003etablespace_map\u003c/code\u003e file that is included in the \u003ccode class=\"filename\"\u003ebase.tar\u003c/code\u003e file.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e works with servers of the same or older major version, down to 9.1. However, WAL streaming mode (\u003ccode class=\"literal\"\u003e-X stream\u003c/code\u003e) only works with server version 9.3 and later, the tar format (\u003ccode class=\"literal\"\u003e--format=tar\u003c/code\u003e) only works with server version 9.5 and later, and incremental backup (\u003ccode class=\"literal\"\u003e--incremental\u003c/code\u003e) only works with server version 17 and later.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will preserve group permissions for data files if group permissions are enabled on the source cluster.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.9\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eTo create a base backup of the server at \u003ccode class=\"literal\"\u003emydbserver\u003c/code\u003e and store it in the local directory \u003ccode class=\"filename\"\u003e/usr/local/pgsql/data\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -h mydbserver -D /usr/local/pgsql/data\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo create a backup of the local server with one compressed tar file for each tablespace, and store it in the directory \u003ccode class=\"filename\"\u003ebackup\u003c/code\u003e, showing a progress report while running:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -D backup -Ft -z -P\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo create a backup of a single-tablespace local database and compress this with \u003cspan class=\"productname\"\u003ebzip2\u003c/span\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -D - -Ft -X fetch | bzip2 \u0026gt; backup.tar.bz2\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003e(This command will fail if there are multiple tablespaces in the database.)\u003c/p\u003e\n\u003cp\u003eTo create a backup of a local database where the tablespace in \u003ccode class=\"filename\"\u003e/opt/ts\u003c/code\u003e is relocated to \u003ccode class=\"filename\"\u003e./backup/ts\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -D backup/data -T /opt/ts=$(pwd)/backup/ts\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo create a backup of the local server with one tar file for each tablespace compressed with \u003cspan class=\"application\"\u003egzip\u003c/span\u003e at level 9, stored in the directory \u003ccode class=\"filename\"\u003ebackup\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -D backup -Ft --compress=gzip:9\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.10\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/progress-reporting.html#BASEBACKUP-PROGRESS-REPORTING\" title=\"27.4.6. Base Backup Progress Reporting\"\u003eSection 27.4.6\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","manual_path":"app-pgbasebackup.html","options":[{"description":"Sets the target directory to write the output to. pg_basebackup will create this directory (and any missing parent directories) if it does not exist. If it already exists, it must be empty. When the backup is in tar format, the target directory may be specified as - (dash), causing the tar file to be written to stdout . This option is required.","names":["-D directory","--pgdata= directory"],"signature":"-D directory --pgdata= directory","source_url":"/docs/18/app-pgbasebackup.html","summary":"Sets the target directory to write the output to. pg_basebackup will create this directory (and any missing parent directories) if it does not exist. If it already exists, it must be empty."},{"description":"Selects the format for the output. format can be one of the following: p plain Write the output as plain files, with the same layout as the source server's data directory and tablespaces. When the cluster has no additional tablespaces, the whole database will be placed in the target directory. If the cluster contains additional tablespaces, the main data directory will be placed in the target directory, but all other tablespaces will be placed in the same absolute path as they have on the source server. (See --tablespace-mapping to change that.) This is the default format. t tar Write the output as tar files in the target directory. The main data directory's contents will be written to a file named base.tar , and each other tablespace will be written to a separate tar file named after that tablespace's OID. If the target directory is specified as - (dash), the tar contents will be written to standard output, suitable for piping to (for example) gzip . This is only allowed if the cluster has no additional tablespaces and WAL streaming is not used.","names":["-F format","--format= format"],"signature":"-F format --format= format","source_url":"/docs/18/app-pgbasebackup.html","summary":"Selects the format for the output. format can be one of the following:"},{"description":"Performs an incremental backup . The backup manifest for the reference backup must be provided, and will be uploaded to the server, which will respond by sending the requested incremental backup.","names":["-i old_manifest_file","--incremental= old_manifest_file"],"signature":"-i old_manifest_file --incremental= old_manifest_file","source_url":"/docs/18/app-pgbasebackup.html","summary":"Performs an incremental backup . The backup manifest for the reference backup must be provided, and will be uploaded to the server, which will respond by sending the requested incremental backup."},{"description":"Creates a standby.signal file and appends connection settings to the postgresql.auto.conf file in the target directory (or within the base archive file when using tar format). This eases setting up a standby server using the results of the backup. The postgresql.auto.conf file will record the connection settings and, if specified, the replication slot that pg_basebackup is using, so that streaming replication and logical replication slot synchronization will use the same settings later on. The dbname will be recorded only if the dbname was specified explicitly in the connection string or environment variable .","names":["-R","--write-recovery-conf"],"signature":"-R --write-recovery-conf","source_url":"/docs/18/app-pgbasebackup.html","summary":"Creates a standby.signal file and appends connection settings to the postgresql.auto.conf file in the target directory (or within the base archive file when using tar format). This eases setting up a standby server using the results of the backup."},{"description":"Instructs the server where to place the base backup. The default target is client , which specifies that the backup should be sent to the machine where pg_basebackup is running. If the target is instead set to server:/some/path , the backup will be stored on the machine where the server is running in the /some/path directory. Storing a backup on the server requires superuser privileges or having privileges of the pg_write_server_files role. If the target is set to blackhole , the contents are discarded and not stored anywhere. This should only be used for testing purposes, as you will not end up with an actual backup. Since WAL streaming is implemented by pg_basebackup rather than by the server, this option cannot be used together with -Xstream . Since that is the default, when this option is specified, you must also specify either -Xfetch or -Xnone .","names":["-t target","--target= target"],"signature":"-t target --target= target","source_url":"/docs/18/app-pgbasebackup.html","summary":"Instructs the server where to place the base backup. The default target is client , which specifies that the backup should be sent to the machine where pg_basebackup is running. If the target is instead set to server:/some/path , the backup will be stored on the machine where the server is running in the /some/path directory. Storing a backup on the server requires superuser privileges or having privileges of the pg_write_server_files role. If the target is set to blackhole , the contents are discarded and not stored anywhere. This should only be used for testing purposes, as you will not end up with an actual backup."},{"description":"Relocates the tablespace in directory olddir to newdir during the backup. To be effective, olddir must exactly match the path specification of the tablespace as it is defined on the source server. (But it is not an error if there is no tablespace in olddir on the source server.) Meanwhile newdir is a directory in the receiving host's filesystem. As with the main target directory, newdir need not exist already, but if it does exist it must be empty. Both olddir and newdir must be absolute paths. If either path needs to contain an equal sign ( = ), precede that with a backslash. This option can be specified multiple times for multiple tablespaces. If a tablespace is relocated in this way, the symbolic links inside the main data directory are updated to point to the new location. So the new data directory is ready to be used for a new server instance with all tablespaces in the updated locations. Currently, this option only works with plain output format; it is ignored if tar format is selected.","names":["-T olddir = newdir","--tablespace-mapping= olddir = newdir"],"signature":"-T olddir = newdir --tablespace-mapping= olddir = newdir","source_url":"/docs/18/app-pgbasebackup.html","summary":"Relocates the tablespace in directory olddir to newdir during the backup. To be effective, olddir must exactly match the path specification of the tablespace as it is defined on the source server. (But it is not an error if there is no tablespace in olddir on the source server.) Meanwhile newdir is a directory in the receiving host's filesystem. As with the main target directory, newdir need not exist already, but if it does exist it must be empty. Both olddir and newdir must be absolute paths. If either path needs to contain an equal sign ( = ), precede that with a backslash. This option can be specified multiple times for multiple tablespaces."},{"description":"Sets the directory to write WAL (write-ahead log) files to. By default WAL files will be placed in the pg_wal subdirectory of the target directory, but this option can be used to place them elsewhere. waldir must be an absolute path. As with the main target directory, waldir need not exist already, but if it does exist it must be empty. This option can only be specified when the backup is in plain format.","names":["--waldir= waldir"],"signature":"--waldir= waldir","source_url":"/docs/18/app-pgbasebackup.html","summary":"Sets the directory to write WAL (write-ahead log) files to. By default WAL files will be placed in the pg_wal subdirectory of the target directory, but this option can be used to place them elsewhere. waldir must be an absolute path. As with the main target directory, waldir need not exist already, but if it does exist it must be empty. This option can only be specified when the backup is in plain format."},{"description":"Includes the required WAL (write-ahead log) files in the backup. This will include all write-ahead logs generated during the backup. Unless the method none is specified, it is possible to start a postmaster in the target directory without the need to consult the WAL archive, thus making the output a completely standalone backup. The following method s for collecting the write-ahead logs are supported: n none Don't include write-ahead logs in the backup. f fetch The write-ahead log files are collected at the end of the backup. Therefore, it is necessary for the source server's wal_keep_size parameter to be set high enough that the required log data is not removed before the end of the backup. If the required log data has been recycled before it's time to transfer it, the backup will fail and be unusable. When tar format is used, the write-ahead log files will be included in the base.tar file. s stream Stream write-ahead log data while the backup is being taken. This method will open a second connection to the server and start streaming the write-ahead log in parallel while running the backup. Therefore, it will require two replication connections not just one. As long as the client can keep up with the write-ahead log data, using this method requires no extra write-ahead logs to be saved on the source server. When tar format is used, the write-ahead log files will be written to a separate file named pg_wal.tar (if the server is a version earlier than 10, the file will be named pg_xlog.tar ). This value is the default.","names":["-X method","--wal-method= method"],"signature":"-X method --wal-method= method","source_url":"/docs/18/app-pgbasebackup.html","summary":"Includes the required WAL (write-ahead log) files in the backup. This will include all write-ahead logs generated during the backup. Unless the method none is specified, it is possible to start a postmaster in the target directory without the need to consult the WAL archive, thus making the output a completely standalone backup."},{"description":"Enables gzip compression of tar file output, with the default compression level. Compression is only available when using the tar format, and the suffix .gz will automatically be added to all tar filenames.","names":["-z","--gzip"],"signature":"-z --gzip","source_url":"/docs/18/app-pgbasebackup.html","summary":"Enables gzip compression of tar file output, with the default compression level. Compression is only available when using the tar format, and the suffix .gz will automatically be added to all tar filenames."},{"description":"Requests compression of the backup. If client or server is included, it specifies where the compression is to be performed. Compressing on the server will reduce transfer bandwidth but will increase server CPU consumption. The default is client except when --target is used. In that case, the backup is not being sent to the client, so only server compression is sensible. When -Xstream , which is the default, is used, server-side compression will not be applied to the WAL. To compress the WAL, use client-side compression, or specify -Xfetch . The compression method can be set to gzip , lz4 , zstd , none for no compression or an integer (no compression if 0, gzip if greater than 0). A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form keyword or keyword=value . Currently, the supported keywords are level , long , and workers . The detail string cannot be used when the compression method is specified as a plain integer. If no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, gzip compression will be used if the level is greater than 0, and no compression will be used if the level is 0. When the tar format is used with gzip , lz4 , or zstd , the suffix .gz , .lz4 , or .zst , respectively, will be automatically added to all tar filenames. When the plain format is used, client-side compression may not be specified, but it is still possible to request server-side compression. If this is done, the server will compress the backup for transmission, and the client will decompress and extract it. When this option is used in combination with -Xstream , pg_wal.tar will be compressed using gzip if client-side gzip compression is selected, but will not be compressed if any other compression algorithm is selected, or if server-side compression is selected.","names":["-Z level","-Z [{client|server}-] method [: detail ]","--compress= level","--compress=[{client|server}-] method [: detail ]"],"signature":"-Z level -Z [{client|server}-] method [: detail ] --compress= level --compress=[{client|server}-] method [: detail ]","source_url":"/docs/18/app-pgbasebackup.html","summary":"Requests compression of the backup. If client or server is included, it specifies where the compression is to be performed. Compressing on the server will reduce transfer bandwidth but will increase server CPU consumption. The default is client except when --target is used. In that case, the backup is not being sent to the client, so only server compression is sensible. When -Xstream , which is the default, is used, server-side compression will not be applied to the WAL. To compress the WAL, use client-side compression, or specify -Xfetch ."},{"description":"Sets checkpoint mode to fast (immediate) or spread (the default) (see Section 25.3.4 ).","names":["-c {fast|spread}","--checkpoint={fast|spread}"],"signature":"-c {fast|spread} --checkpoint={fast|spread}","source_url":"/docs/18/app-pgbasebackup.html","summary":"Sets checkpoint mode to fast (immediate) or spread (the default) (see Section 25.3.4 )."},{"description":"Specifies that the replication slot named by the --slot option should be created before starting the backup. An error is raised if the slot already exists.","names":["-C","--create-slot"],"signature":"-C --create-slot","source_url":"/docs/18/app-pgbasebackup.html","summary":"Specifies that the replication slot named by the --slot option should be created before starting the backup. An error is raised if the slot already exists."},{"description":"Sets the label for the backup. If none is specified, a default value of “ pg_basebackup base backup ” will be used.","names":["-l label","--label= label"],"signature":"-l label --label= label","source_url":"/docs/18/app-pgbasebackup.html","summary":"Sets the label for the backup. If none is specified, a default value of “ pg_basebackup base backup ” will be used."},{"description":"By default, when pg_basebackup aborts with an error, it removes any directories it might have created before discovering that it cannot finish the job (for example, the target directory and write-ahead log directory). This option inhibits tidying-up and is thus useful for debugging. Note that tablespace directories are not cleaned up either way.","names":["-n","--no-clean"],"signature":"-n --no-clean","source_url":"/docs/18/app-pgbasebackup.html","summary":"By default, when pg_basebackup aborts with an error, it removes any directories it might have created before discovering that it cannot finish the job (for example, the target directory and write-ahead log directory). This option inhibits tidying-up and is thus useful for debugging."},{"description":"By default, pg_basebackup will wait for all files to be written safely to disk. This option causes pg_basebackup to return without waiting, which is faster, but means that a subsequent operating system crash can leave the base backup corrupt. Generally, this option is useful for testing but should not be used when creating a production installation.","names":["-N","--no-sync"],"signature":"-N --no-sync","source_url":"/docs/18/app-pgbasebackup.html","summary":"By default, pg_basebackup will wait for all files to be written safely to disk. This option causes pg_basebackup to return without waiting, which is faster, but means that a subsequent operating system crash can leave the base backup corrupt. Generally, this option is useful for testing but should not be used when creating a production installation."},{"description":"Enables progress reporting. Turning this on will deliver an approximate progress report during the backup. Since the database may change during the backup, this is only an approximation and may not end at exactly 100% . In particular, when WAL log is included in the backup, the total amount of data cannot be estimated in advance, and in this case the estimated target size will increase once it passes the total estimate without WAL.","names":["-P","--progress"],"signature":"-P --progress","source_url":"/docs/18/app-pgbasebackup.html","summary":"Enables progress reporting. Turning this on will deliver an approximate progress report during the backup. Since the database may change during the backup, this is only an approximation and may not end at exactly 100% . In particular, when WAL log is included in the backup, the total amount of data cannot be estimated in advance, and in this case the estimated target size will increase once it passes the total estimate without WAL."},{"description":"Sets the maximum transfer rate at which data is collected from the source server. This can be useful to limit the impact of pg_basebackup on the server. Values are in kilobytes per second. Use a suffix of M to indicate megabytes per second. A suffix of k is also accepted, and has no effect. Valid values are between 32 kilobytes per second and 1024 megabytes per second. This option always affects transfer of the data directory. Transfer of WAL files is only affected if the collection method is fetch .","names":["-r rate","--max-rate= rate"],"signature":"-r rate --max-rate= rate","source_url":"/docs/18/app-pgbasebackup.html","summary":"Sets the maximum transfer rate at which data is collected from the source server. This can be useful to limit the impact of pg_basebackup on the server. Values are in kilobytes per second. Use a suffix of M to indicate megabytes per second. A suffix of k is also accepted, and has no effect. Valid values are between 32 kilobytes per second and 1024 megabytes per second."},{"description":"This option can only be used together with -X stream . It causes WAL streaming to use the specified replication slot. If the base backup is intended to be used as a streaming-replication standby using a replication slot, the standby should then use the same replication slot name as primary_slot_name . This ensures that the primary server does not remove any necessary WAL data in the time between the end of the base backup and the start of streaming replication on the new standby. The specified replication slot has to exist unless the option -C is also used. If this option is not specified and the server supports temporary replication slots (version 10 and later), then a temporary replication slot is automatically used for WAL streaming.","names":["-S slotname","--slot= slotname"],"signature":"-S slotname --slot= slotname","source_url":"/docs/18/app-pgbasebackup.html","summary":"This option can only be used together with -X stream . It causes WAL streaming to use the specified replication slot. If the base backup is intended to be used as a streaming-replication standby using a replication slot, the standby should then use the same replication slot name as primary_slot_name . This ensures that the primary server does not remove any necessary WAL data in the time between the end of the base backup and the start of streaming replication on the new standby."},{"description":"When set to fsync , which is the default, pg_basebackup will recursively open and synchronize all files in the backup directory. When the plain format is used, the search for files will follow symbolic links for the WAL directory and each configured tablespace. On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the backup directory. When the plain format is used, pg_basebackup will also synchronize the file systems that contain the WAL files and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs . This option has no effect when --no-sync is used.","names":["--sync-method= method"],"signature":"--sync-method= method","source_url":"/docs/18/app-pgbasebackup.html","summary":"When set to fsync , which is the default, pg_basebackup will recursively open and synchronize all files in the backup directory. When the plain format is used, the search for files will follow symbolic links for the WAL directory and each configured tablespace."},{"description":"Enables verbose mode. Will output some extra steps during startup and shutdown, as well as show the exact file name that is currently being processed if progress reporting is also enabled.","names":["-v","--verbose"],"signature":"-v --verbose","source_url":"/docs/18/app-pgbasebackup.html","summary":"Enables verbose mode. Will output some extra steps during startup and shutdown, as well as show the exact file name that is currently being processed if progress reporting is also enabled."},{"description":"Specifies the checksum algorithm that should be applied to each file included in the backup manifest. Currently, the available algorithms are NONE , CRC32C , SHA224 , SHA256 , SHA384 , and SHA512 . The default is CRC32C . If NONE is selected, the backup manifest will not contain any checksums. Otherwise, it will contain a checksum of each file in the backup using the specified algorithm. In addition, the manifest will always contain a SHA256 checksum of its own contents. The SHA algorithms are significantly more CPU-intensive than CRC32C , so selecting one of them may increase the time required to complete the backup. Using a SHA hash function provides a cryptographically secure digest of each file for users who wish to verify that the backup has not been tampered with, while the CRC-32C algorithm provides a checksum that is much faster to calculate; it is good at catching errors due to accidental changes but is not resistant to malicious modifications. Note that, to be useful against an adversary who has access to the backup, the backup manifest would need to be stored securely elsewhere or otherwise verified not to have been modified since the backup was taken. pg_verifybackup can be used to check the integrity of a backup against the backup manifest.","names":["--manifest-checksums= algorithm"],"signature":"--manifest-checksums= algorithm","source_url":"/docs/18/app-pgbasebackup.html","summary":"Specifies the checksum algorithm that should be applied to each file included in the backup manifest. Currently, the available algorithms are NONE , CRC32C , SHA224 , SHA256 , SHA384 , and SHA512 . The default is CRC32C ."},{"description":"Forces all filenames in the backup manifest to be hex-encoded. If this option is not specified, only non-UTF8 filenames are hex-encoded. This option is mostly intended to test that tools which read a backup manifest file properly handle this case.","names":["--manifest-force-encode"],"signature":"--manifest-force-encode","source_url":"/docs/18/app-pgbasebackup.html","summary":"Forces all filenames in the backup manifest to be hex-encoded. If this option is not specified, only non-UTF8 filenames are hex-encoded. This option is mostly intended to test that tools which read a backup manifest file properly handle this case."},{"description":"Prevents the server from estimating the total amount of backup data that will be streamed, resulting in the backup_total column in the pg_stat_progress_basebackup view always being NULL . Without this option, the backup will start by enumerating the size of the entire database, and then go back and send the actual contents. This may make the backup take slightly longer, and in particular it will take longer before the first data is sent. This option is useful to avoid such estimation time if it's too long. This option is not allowed when using --progress .","names":["--no-estimate-size"],"signature":"--no-estimate-size","source_url":"/docs/18/app-pgbasebackup.html","summary":"Prevents the server from estimating the total amount of backup data that will be streamed, resulting in the backup_total column in the pg_stat_progress_basebackup view always being NULL ."},{"description":"Disables generation of a backup manifest. If this option is not specified, the server will generate and send a backup manifest which can be verified using pg_verifybackup . The manifest is a list of every file present in the backup with the exception of any WAL files that may be included. It also stores the size, last modification time, and an optional checksum for each file.","names":["--no-manifest"],"signature":"--no-manifest","source_url":"/docs/18/app-pgbasebackup.html","summary":"Disables generation of a backup manifest. If this option is not specified, the server will generate and send a backup manifest which can be verified using pg_verifybackup . The manifest is a list of every file present in the backup with the exception of any WAL files that may be included. It also stores the size, last modification time, and an optional checksum for each file."},{"description":"Prevents the creation of a temporary replication slot for the backup. By default, if log streaming is selected but no slot name is given with the -S option, then a temporary replication slot is created (if supported by the source server). The main purpose of this option is to allow taking a base backup when the server has no free replication slots. Using a replication slot is almost always preferred, because it prevents needed WAL from being removed by the server during the backup.","names":["--no-slot"],"signature":"--no-slot","source_url":"/docs/18/app-pgbasebackup.html","summary":"Prevents the creation of a temporary replication slot for the backup."},{"description":"Disables verification of checksums, if they are enabled on the server the base backup is taken from. By default, checksums are verified and checksum failures will result in a non-zero exit status. However, the base backup will not be removed in such a case, as if the --no-clean option had been used. Checksum verification failures will also be reported in the pg_stat_database view.","names":["--no-verify-checksums"],"signature":"--no-verify-checksums","source_url":"/docs/18/app-pgbasebackup.html","summary":"Disables verification of checksums, if they are enabled on the server the base backup is taken from."},{"description":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options. This option is called --dbname for consistency with other client applications, but because pg_basebackup doesn't connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name ( replication ) for purposes of looking up the replication connection's password in ~/.pgpass . Similarly, middleware or proxies used in connecting to PostgreSQL might utilize the name for purposes such as connection routing. The database name can also be used by logical replication slot synchronization .","names":["-d connstr","--dbname= connstr"],"signature":"-d connstr --dbname= connstr","source_url":"/docs/18/app-pgbasebackup.html","summary":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options."},{"description":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for a Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted.","names":["-h host","--host= host"],"signature":"-h host --host= host","source_url":"/docs/18/app-pgbasebackup.html","summary":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for a Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted."},{"description":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default.","names":["-p port","--port= port"],"signature":"-p port --port= port","source_url":"/docs/18/app-pgbasebackup.html","summary":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default."},{"description":"Specifies the number of seconds between status packets sent back to the source server. Smaller values allow more accurate monitoring of backup progress from the server. A value of zero disables periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout-based disconnects. The default value is 10 seconds.","names":["-s interval","--status-interval= interval"],"signature":"-s interval --status-interval= interval","source_url":"/docs/18/app-pgbasebackup.html","summary":"Specifies the number of seconds between status packets sent back to the source server. Smaller values allow more accurate monitoring of backup progress from the server. A value of zero disables periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout-based disconnects. The default value is 10 seconds."},{"description":"Specifies the user name to connect as.","names":["-U username","--username= username"],"signature":"-U username --username= username","source_url":"/docs/18/app-pgbasebackup.html","summary":"Specifies the user name to connect as."},{"description":"Prevents issuing a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.","names":["-w","--no-password"],"signature":"-w --no-password","source_url":"/docs/18/app-pgbasebackup.html","summary":"Prevents issuing a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"description":"Forces pg_basebackup to prompt for a password before connecting to the source server. This option is never essential, since pg_basebackup will automatically prompt for a password if the server demands password authentication. However, pg_basebackup will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing -W to avoid the extra connection attempt.","names":["-W","--password"],"signature":"-W --password","source_url":"/docs/18/app-pgbasebackup.html","summary":"Forces pg_basebackup to prompt for a password before connecting to the source server."},{"description":"Prints the pg_basebackup version and exits.","names":["-V","--version"],"signature":"-V --version","source_url":"/docs/18/app-pgbasebackup.html","summary":"Prints the pg_basebackup version and exits."},{"description":"Shows help about pg_basebackup command line arguments, and exits.","names":["-?","--help"],"signature":"-? --help","source_url":"/docs/18/app-pgbasebackup.html","summary":"Shows help about pg_basebackup command line arguments, and exits."}],"related":[{"label":"libpq connection parameters","url":"/wiki/conn/?v=18"}],"release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sections":[],"signature":"pg_basebackup [ option ...]","sources":[{"anchor":"","file":"app-pgbasebackup.html","label":"18.6 English manual · app-pgbasebackup.html","sha256":"76780bc785b5bf8a7b20cdc1678b3e8d1de6aafb9cc46df9e578012d4f71546b","url":"/docs/18/app-pgbasebackup.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","url":"/docs/18/reference-client.html"}],"synopsis":["pg_basebackup [ option ...]"],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-D directory --pgdata= directory","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets the target directory to write the output to. pg_basebackup will create this directory (and any missing parent directories) if it does not exist. If it already exists, it must be empty."},{"signature":{"text":"-F format --format= format","url":"/docs/18/app-pgbasebackup.html"},"summary":"Selects the format for the output. format can be one of the following:"},{"signature":{"text":"-i old_manifest_file --incremental= old_manifest_file","url":"/docs/18/app-pgbasebackup.html"},"summary":"Performs an incremental backup . The backup manifest for the reference backup must be provided, and will be uploaded to the server, which will respond by sending the requested incremental backup."},{"signature":{"text":"-R --write-recovery-conf","url":"/docs/18/app-pgbasebackup.html"},"summary":"Creates a standby.signal file and appends connection settings to the postgresql.auto.conf file in the target directory (or within the base archive file when using tar format). This eases setting up a standby server using the results of the backup."},{"signature":{"text":"-t target --target= target","url":"/docs/18/app-pgbasebackup.html"},"summary":"Instructs the server where to place the base backup. The default target is client , which specifies that the backup should be sent to the machine where pg_basebackup is running. If the target is instead set to server:/some/path , the backup will be stored on the machine where the server is running in the /some/path directory. Storing a backup on the server requires superuser privileges or having privileges of the pg_write_server_files role. If the target is set to blackhole , the contents are discarded and not stored anywhere. This should only be used for testing purposes, as you will not end up with an actual backup."},{"signature":{"text":"-T olddir = newdir --tablespace-mapping= olddir = newdir","url":"/docs/18/app-pgbasebackup.html"},"summary":"Relocates the tablespace in directory olddir to newdir during the backup. To be effective, olddir must exactly match the path specification of the tablespace as it is defined on the source server. (But it is not an error if there is no tablespace in olddir on the source server.) Meanwhile newdir is a directory in the receiving host's filesystem. As with the main target directory, newdir need not exist already, but if it does exist it must be empty. Both olddir and newdir must be absolute paths. If either path needs to contain an equal sign ( = ), precede that with a backslash. This option can be specified multiple times for multiple tablespaces."},{"signature":{"text":"--waldir= waldir","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets the directory to write WAL (write-ahead log) files to. By default WAL files will be placed in the pg_wal subdirectory of the target directory, but this option can be used to place them elsewhere. waldir must be an absolute path. As with the main target directory, waldir need not exist already, but if it does exist it must be empty. This option can only be specified when the backup is in plain format."},{"signature":{"text":"-X method --wal-method= method","url":"/docs/18/app-pgbasebackup.html"},"summary":"Includes the required WAL (write-ahead log) files in the backup. This will include all write-ahead logs generated during the backup. Unless the method none is specified, it is possible to start a postmaster in the target directory without the need to consult the WAL archive, thus making the output a completely standalone backup."},{"signature":{"text":"-z --gzip","url":"/docs/18/app-pgbasebackup.html"},"summary":"Enables gzip compression of tar file output, with the default compression level. Compression is only available when using the tar format, and the suffix .gz will automatically be added to all tar filenames."},{"signature":{"text":"-Z level -Z [{client|server}-] method [: detail ] --compress= level --compress=[{client|server}-] method [: detail ]","url":"/docs/18/app-pgbasebackup.html"},"summary":"Requests compression of the backup. If client or server is included, it specifies where the compression is to be performed. Compressing on the server will reduce transfer bandwidth but will increase server CPU consumption. The default is client except when --target is used. In that case, the backup is not being sent to the client, so only server compression is sensible. When -Xstream , which is the default, is used, server-side compression will not be applied to the WAL. To compress the WAL, use client-side compression, or specify -Xfetch ."},{"signature":{"text":"-c {fast|spread} --checkpoint={fast|spread}","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets checkpoint mode to fast (immediate) or spread (the default) (see Section 25.3.4 )."},{"signature":{"text":"-C --create-slot","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies that the replication slot named by the --slot option should be created before starting the backup. An error is raised if the slot already exists."},{"signature":{"text":"-l label --label= label","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets the label for the backup. If none is specified, a default value of “ pg_basebackup base backup ” will be used."},{"signature":{"text":"-n --no-clean","url":"/docs/18/app-pgbasebackup.html"},"summary":"By default, when pg_basebackup aborts with an error, it removes any directories it might have created before discovering that it cannot finish the job (for example, the target directory and write-ahead log directory). This option inhibits tidying-up and is thus useful for debugging."},{"signature":{"text":"-N --no-sync","url":"/docs/18/app-pgbasebackup.html"},"summary":"By default, pg_basebackup will wait for all files to be written safely to disk. This option causes pg_basebackup to return without waiting, which is faster, but means that a subsequent operating system crash can leave the base backup corrupt. Generally, this option is useful for testing but should not be used when creating a production installation."},{"signature":{"text":"-P --progress","url":"/docs/18/app-pgbasebackup.html"},"summary":"Enables progress reporting. Turning this on will deliver an approximate progress report during the backup. Since the database may change during the backup, this is only an approximation and may not end at exactly 100% . In particular, when WAL log is included in the backup, the total amount of data cannot be estimated in advance, and in this case the estimated target size will increase once it passes the total estimate without WAL."},{"signature":{"text":"-r rate --max-rate= rate","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets the maximum transfer rate at which data is collected from the source server. This can be useful to limit the impact of pg_basebackup on the server. Values are in kilobytes per second. Use a suffix of M to indicate megabytes per second. A suffix of k is also accepted, and has no effect. Valid values are between 32 kilobytes per second and 1024 megabytes per second."},{"signature":{"text":"-S slotname --slot= slotname","url":"/docs/18/app-pgbasebackup.html"},"summary":"This option can only be used together with -X stream . It causes WAL streaming to use the specified replication slot. If the base backup is intended to be used as a streaming-replication standby using a replication slot, the standby should then use the same replication slot name as primary_slot_name . This ensures that the primary server does not remove any necessary WAL data in the time between the end of the base backup and the start of streaming replication on the new standby."},{"signature":{"text":"--sync-method= method","url":"/docs/18/app-pgbasebackup.html"},"summary":"When set to fsync , which is the default, pg_basebackup will recursively open and synchronize all files in the backup directory. When the plain format is used, the search for files will follow symbolic links for the WAL directory and each configured tablespace."},{"signature":{"text":"-v --verbose","url":"/docs/18/app-pgbasebackup.html"},"summary":"Enables verbose mode. Will output some extra steps during startup and shutdown, as well as show the exact file name that is currently being processed if progress reporting is also enabled."},{"signature":{"text":"--manifest-checksums= algorithm","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the checksum algorithm that should be applied to each file included in the backup manifest. Currently, the available algorithms are NONE , CRC32C , SHA224 , SHA256 , SHA384 , and SHA512 . The default is CRC32C ."},{"signature":{"text":"--manifest-force-encode","url":"/docs/18/app-pgbasebackup.html"},"summary":"Forces all filenames in the backup manifest to be hex-encoded. If this option is not specified, only non-UTF8 filenames are hex-encoded. This option is mostly intended to test that tools which read a backup manifest file properly handle this case."},{"signature":{"text":"--no-estimate-size","url":"/docs/18/app-pgbasebackup.html"},"summary":"Prevents the server from estimating the total amount of backup data that will be streamed, resulting in the backup_total column in the pg_stat_progress_basebackup view always being NULL ."},{"signature":{"text":"--no-manifest","url":"/docs/18/app-pgbasebackup.html"},"summary":"Disables generation of a backup manifest. If this option is not specified, the server will generate and send a backup manifest which can be verified using pg_verifybackup . The manifest is a list of every file present in the backup with the exception of any WAL files that may be included. It also stores the size, last modification time, and an optional checksum for each file."},{"signature":{"text":"--no-slot","url":"/docs/18/app-pgbasebackup.html"},"summary":"Prevents the creation of a temporary replication slot for the backup."},{"signature":{"text":"--no-verify-checksums","url":"/docs/18/app-pgbasebackup.html"},"summary":"Disables verification of checksums, if they are enabled on the server the base backup is taken from."},{"signature":{"text":"-d connstr --dbname= connstr","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options."},{"signature":{"text":"-h host --host= host","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for a Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted."},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default."},{"signature":{"text":"-s interval --status-interval= interval","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the number of seconds between status packets sent back to the source server. Smaller values allow more accurate monitoring of backup progress from the server. A value of zero disables periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout-based disconnects. The default value is 10 seconds."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the user name to connect as."},{"signature":{"text":"-w --no-password","url":"/docs/18/app-pgbasebackup.html"},"summary":"Prevents issuing a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"signature":{"text":"-W --password","url":"/docs/18/app-pgbasebackup.html"},"summary":"Forces pg_basebackup to prompt for a password before connecting to the source server."},{"signature":{"text":"-V --version","url":"/docs/18/app-pgbasebackup.html"},"summary":"Prints the pg_basebackup version and exits."},{"signature":{"text":"-? --help","url":"/docs/18/app-pgbasebackup.html"},"summary":"Shows help about pg_basebackup command line arguments, and exits."}],"title":"Documented options"}]},"ManualEvidence":{"manual_path":"app-pgbasebackup.html","release":{"channel":"stable","evidence_kind":"English manual and source declarations","label":"18.6","major":"18","manifest":{"index":"index.html","major":"18","pages":1148,"pdf":{"A4":{"built_at":"2026-09-26","bytes":15865106,"pages":3154,"sha256":"19512c405da53f9f7fcf0abba359223aa65f021be025bf3411381918f92e3190","url":"/files/documentation/pdf/18/postgresql-18-A4.pdf"},"US":{"built_at":"2026-09-26","bytes":15748059,"pages":3328,"sha256":"facbe6c229e598b872d3d98bef53308f46e06746006fa4590de9a7de9dd46319","url":"/files/documentation/pdf/18/postgresql-18-US.pdf"}},"release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","svg_assets":3,"tree":"18"},"ref":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2","revision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"},"sources":[{"anchor":"","file":"app-pgbasebackup.html","label":"18.6 English manual · app-pgbasebackup.html","sha256":"76780bc785b5bf8a7b20cdc1678b3e8d1de6aafb9cc46df9e578012d4f71546b","url":"/docs/18/app-pgbasebackup.html"},{"anchor":"","file":"reference-client.html","label":"Client applications inventory","sha256":"68f726af77272fe73a827be2b7b5958d0f2239a6f8ed44264e9d42496bfa4fd0","url":"/docs/18/reference-client.html"}]},"MeasuredEvidence":{}},"Text":{"Collection":"tool","Key":"pg-basebackup","SourceDatabase":"center","Version":"18","Locale":"en","Title":"pg_basebackup","Summary":"pg_basebackup — take a base backup of a PostgreSQL cluster","BodyHTML":"\u003cdiv\u003e\u003cdiv id=\"APP-PGBASEBACKUP\"\u003e\n\u003cdiv\u003e\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003e\u003cspan\u003e\u003cspan\u003epg_basebackup\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_basebackup — take a base backup of a \u003cspan\u003ePostgreSQL\u003c/span\u003e cluster\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv\u003e\n\u003cp id=\"id-1.9.4.10.4.1\"\u003e\u003ccode\u003epg_basebackup\u003c/code\u003e [\u003cem\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.10.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan\u003epg_basebackup\u003c/span\u003e is used to take a base backup of a running \u003cspan\u003ePostgreSQL\u003c/span\u003e database cluster. The backup is taken without affecting other clients of the database, and can be used both for point-in-time recovery (see \u003ca href=\"/docs/18/continuous-archiving.html\" rel=\"nofollow\"\u003eSection 25.3\u003c/a\u003e) and as the starting point for a log-shipping or streaming-replication standby server (see \u003ca href=\"/docs/18/warm-standby.html\" rel=\"nofollow\"\u003eSection 26.2\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003epg_basebackup\u003c/span\u003e can take a full or incremental base backup of the database. When used to take a full backup, it makes an exact copy of the database cluster\u0026#39;s files. When used to take an incremental backup, some files that would have been part of a full backup may be replaced with incremental versions of the same files, containing only those blocks that have been modified since the reference backup. An incremental backup cannot be used directly; instead, \u003ca href=\"/docs/18/app-pgcombinebackup.html\" title=\"pg_combinebackup\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_combinebackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e must first be used to combine it with the previous backups upon which it depends. See \u003ca href=\"/docs/18/continuous-archiving.html#BACKUP-INCREMENTAL-BACKUP\" rel=\"nofollow\"\u003eSection 25.3.3\u003c/a\u003e for more information about incremental backups, and \u003ca href=\"/docs/18/continuous-archiving.html#BACKUP-PITR-RECOVERY\" rel=\"nofollow\"\u003eSection 25.3.5\u003c/a\u003e for steps to recover from a backup.\u003c/p\u003e\n\u003cp\u003eIn any mode, \u003cspan\u003epg_basebackup\u003c/span\u003e makes sure the server is put into and out of backup mode automatically. Backups are always taken of the entire database cluster; it is not possible to back up individual databases or database objects. For selective backups, another tool such as \u003ca href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e must be used.\u003c/p\u003e\n\u003cp\u003eThe backup is made over a regular \u003cspan\u003ePostgreSQL\u003c/span\u003e connection that uses the replication protocol. The connection must be made with a user ID that has \u003ccode\u003eREPLICATION\u003c/code\u003e permissions (see \u003ca href=\"/docs/18/role-attributes.html\" rel=\"nofollow\"\u003eSection 21.2\u003c/a\u003e) or is a superuser, and \u003ca href=\"/docs/18/auth-pg-hba-conf.html\" rel=\"nofollow\"\u003e\u003ccode\u003epg_hba.conf\u003c/code\u003e\u003c/a\u003e must permit the replication connection. The server must also be configured with \u003ca href=\"/docs/18/runtime-config-replication.html#GUC-MAX-WAL-SENDERS\" rel=\"nofollow\"\u003emax_wal_senders\u003c/a\u003e set high enough to provide at least one walsender for the backup plus one for WAL streaming (if used).\u003c/p\u003e\n\u003cp\u003eThere can be multiple \u003ccode\u003epg_basebackup\u003c/code\u003es running at the same time, but it is usually better from a performance point of view to take only one backup, and copy the result.\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003epg_basebackup\u003c/span\u003e can make a base backup from not only a primary server but also a standby. To take a backup from a standby, set up the standby so that it can accept replication connections (that is, set \u003ccode\u003emax_wal_senders\u003c/code\u003e and \u003ca href=\"/docs/18/runtime-config-replication.html#GUC-HOT-STANDBY\" rel=\"nofollow\"\u003ehot_standby\u003c/a\u003e, and configure its \u003ccode\u003epg_hba.conf\u003c/code\u003e appropriately). You will also need to enable \u003ca href=\"/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\" rel=\"nofollow\"\u003efull_page_writes\u003c/a\u003e on the primary.\u003c/p\u003e\n\u003cp\u003eNote that there are some limitations in taking a backup from a standby:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cul\u003e\n\u003cli\u003e\n\u003cp\u003eThe backup history file is not created in the database cluster backed up.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003e\u003cspan\u003epg_basebackup\u003c/span\u003e cannot force the standby to switch to a new WAL file at the end of backup. When you are using \u003ccode\u003e-X none\u003c/code\u003e, if write activity on the primary is low, \u003cspan\u003epg_basebackup\u003c/span\u003e may need to wait a long time for the last WAL file required for the backup to be switched and archived. In this case, it may be useful to run \u003ccode\u003epg_switch_wal\u003c/code\u003e on the primary in order to trigger an immediate WAL file switch.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eIf the standby is promoted to be primary during backup, the backup fails.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli\u003e\n\u003cp\u003eAll WAL records required for the backup must contain sufficient full-page writes, which requires you to enable \u003ccode\u003efull_page_writes\u003c/code\u003e on the primary.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eWhenever \u003cspan\u003epg_basebackup\u003c/span\u003e is taking a base backup, the server\u0026#39;s \u003ccode\u003epg_stat_progress_basebackup\u003c/code\u003e view will report the progress of the backup. See \u003ca href=\"/docs/18/progress-reporting.html#BASEBACKUP-PROGRESS-REPORTING\" rel=\"nofollow\"\u003eSection 27.4.6\u003c/a\u003e for details.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.10.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cp\u003eThe following command-line options control the location and format of the output:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-D \u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--pgdata=\u003cem\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the target directory to write the output to. \u003cspan\u003epg_basebackup\u003c/span\u003e will create this directory (and any missing parent directories) if it does not exist. If it already exists, it must be empty.\u003c/p\u003e\n\u003cp\u003eWhen the backup is in tar format, the target directory may be specified as \u003ccode\u003e-\u003c/code\u003e (dash), causing the tar file to be written to \u003ccode\u003estdout\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option is required.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-F \u003cem\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--format=\u003cem\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSelects the format for the output. \u003cem\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e can be one of the following:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ep\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003eplain\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite the output as plain files, with the same layout as the source server\u0026#39;s data directory and tablespaces. When the cluster has no additional tablespaces, the whole database will be placed in the target directory. If the cluster contains additional tablespaces, the main data directory will be placed in the target directory, but all other tablespaces will be placed in the same absolute path as they have on the source server. (See \u003ccode\u003e--tablespace-mapping\u003c/code\u003e to change that.)\u003c/p\u003e\n\u003cp\u003eThis is the default format.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003et\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003etar\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite the output as tar files in the target directory. The main data directory\u0026#39;s contents will be written to a file named \u003ccode\u003ebase.tar\u003c/code\u003e, and each other tablespace will be written to a separate tar file named after that tablespace\u0026#39;s OID.\u003c/p\u003e\n\u003cp\u003eIf the target directory is specified as \u003ccode\u003e-\u003c/code\u003e (dash), the tar contents will be written to standard output, suitable for piping to (for example) \u003cspan\u003egzip\u003c/span\u003e. This is only allowed if the cluster has no additional tablespaces and WAL streaming is not used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-i \u003cem\u003e\u003ccode\u003eold_manifest_file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--incremental=\u003cem\u003e\u003ccode\u003eold_manifest_file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerforms an \u003ca href=\"/docs/18/continuous-archiving.html#BACKUP-INCREMENTAL-BACKUP\" rel=\"nofollow\"\u003eincremental backup\u003c/a\u003e. The backup manifest for the reference backup must be provided, and will be uploaded to the server, which will respond by sending the requested incremental backup.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-R\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--write-recovery-conf\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreates a \u003ca href=\"/docs/18/warm-standby.html#FILE-STANDBY-SIGNAL\" rel=\"nofollow\"\u003e\u003ccode\u003estandby.signal\u003c/code\u003e\u003c/a\u003e  file and appends connection settings to the \u003ccode\u003epostgresql.auto.conf\u003c/code\u003e file in the target directory (or within the base archive file when using tar format). This eases setting up a standby server using the results of the backup.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode\u003epostgresql.auto.conf\u003c/code\u003e file will record the connection settings and, if specified, the replication slot that \u003cspan\u003epg_basebackup\u003c/span\u003e is using, so that streaming replication and \u003ca href=\"/docs/18/logicaldecoding-explanation.html#LOGICALDECODING-REPLICATION-SLOTS-SYNCHRONIZATION\" rel=\"nofollow\"\u003elogical replication slot synchronization\u003c/a\u003e will use the same settings later on. The dbname will be recorded only if the dbname was specified explicitly in the connection string or \u003ca href=\"/docs/18/libpq-envars.html\" rel=\"nofollow\"\u003eenvironment variable\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-t \u003cem\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--target=\u003cem\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eInstructs the server where to place the base backup. The default target is \u003ccode\u003eclient\u003c/code\u003e, which specifies that the backup should be sent to the machine where \u003cspan\u003epg_basebackup\u003c/span\u003e is running. If the target is instead set to \u003ccode\u003eserver:/some/path\u003c/code\u003e, the backup will be stored on the machine where the server is running in the \u003ccode\u003e/some/path\u003c/code\u003e directory. Storing a backup on the server requires superuser privileges or having privileges of the \u003ccode\u003epg_write_server_files\u003c/code\u003e role. If the target is set to \u003ccode\u003eblackhole\u003c/code\u003e, the contents are discarded and not stored anywhere. This should only be used for testing purposes, as you will not end up with an actual backup.\u003c/p\u003e\n\u003cp\u003eSince WAL streaming is implemented by \u003cspan\u003epg_basebackup\u003c/span\u003e rather than by the server, this option cannot be used together with \u003ccode\u003e-Xstream\u003c/code\u003e. Since that is the default, when this option is specified, you must also specify either \u003ccode\u003e-Xfetch\u003c/code\u003e or \u003ccode\u003e-Xnone\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-T \u003cem\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e=\u003cem\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--tablespace-mapping=\u003cem\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e=\u003cem\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRelocates the tablespace in directory \u003cem\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e to \u003cem\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e during the backup. To be effective, \u003cem\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e must exactly match the path specification of the tablespace as it is defined on the source server. (But it is not an error if there is no tablespace in \u003cem\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e on the source server.) Meanwhile \u003cem\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e is a directory in the receiving host\u0026#39;s filesystem. As with the main target directory, \u003cem\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e need not exist already, but if it does exist it must be empty. Both \u003cem\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e and \u003cem\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e must be absolute paths. If either path needs to contain an equal sign (\u003ccode\u003e=\u003c/code\u003e), precede that with a backslash. This option can be specified multiple times for multiple tablespaces.\u003c/p\u003e\n\u003cp\u003eIf a tablespace is relocated in this way, the symbolic links inside the main data directory are updated to point to the new location. So the new data directory is ready to be used for a new server instance with all tablespaces in the updated locations.\u003c/p\u003e\n\u003cp\u003eCurrently, this option only works with plain output format; it is ignored if tar format is selected.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--waldir=\u003cem\u003e\u003ccode\u003ewaldir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the directory to write WAL (write-ahead log) files to. By default WAL files will be placed in the \u003ccode\u003epg_wal\u003c/code\u003e subdirectory of the target directory, but this option can be used to place them elsewhere. \u003cem\u003e\u003ccode\u003ewaldir\u003c/code\u003e\u003c/em\u003e must be an absolute path. As with the main target directory, \u003cem\u003e\u003ccode\u003ewaldir\u003c/code\u003e\u003c/em\u003e need not exist already, but if it does exist it must be empty. This option can only be specified when the backup is in plain format.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-X \u003cem\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--wal-method=\u003cem\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIncludes the required WAL (write-ahead log) files in the backup. This will include all write-ahead logs generated during the backup. Unless the method \u003ccode\u003enone\u003c/code\u003e is specified, it is possible to start a postmaster in the target directory without the need to consult the WAL archive, thus making the output a completely standalone backup.\u003c/p\u003e\n\u003cp\u003eThe following \u003cem\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003es for collecting the write-ahead logs are supported:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003en\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003enone\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDon\u0026#39;t include write-ahead logs in the backup.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003ef\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003efetch\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe write-ahead log files are collected at the end of the backup. Therefore, it is necessary for the source server\u0026#39;s \u003ca href=\"/docs/18/runtime-config-replication.html#GUC-WAL-KEEP-SIZE\" rel=\"nofollow\"\u003ewal_keep_size\u003c/a\u003e parameter to be set high enough that the required log data is not removed before the end of the backup. If the required log data has been recycled before it\u0026#39;s time to transfer it, the backup will fail and be unusable.\u003c/p\u003e\n\u003cp\u003eWhen tar format is used, the write-ahead log files will be included in the \u003ccode\u003ebase.tar\u003c/code\u003e file.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003es\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003estream\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eStream write-ahead log data while the backup is being taken. This method will open a second connection to the server and start streaming the write-ahead log in parallel while running the backup. Therefore, it will require two replication connections not just one. As long as the client can keep up with the write-ahead log data, using this method requires no extra write-ahead logs to be saved on the source server.\u003c/p\u003e\n\u003cp\u003eWhen tar format is used, the write-ahead log files will be written to a separate file named \u003ccode\u003epg_wal.tar\u003c/code\u003e (if the server is a version earlier than 10, the file will be named \u003ccode\u003epg_xlog.tar\u003c/code\u003e).\u003c/p\u003e\n\u003cp\u003eThis value is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-z\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--gzip\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables gzip compression of tar file output, with the default compression level. Compression is only available when using the tar format, and the suffix \u003ccode\u003e.gz\u003c/code\u003e will automatically be added to all tar filenames.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-Z \u003cem\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e-Z [{client|server}-]\u003cem\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--compress=\u003cem\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--compress=[{client|server}-]\u003cem\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequests compression of the backup. If \u003ccode\u003eclient\u003c/code\u003e or \u003ccode\u003eserver\u003c/code\u003e is included, it specifies where the compression is to be performed. Compressing on the server will reduce transfer bandwidth but will increase server CPU consumption. The default is \u003ccode\u003eclient\u003c/code\u003e except when \u003ccode\u003e--target\u003c/code\u003e is used. In that case, the backup is not being sent to the client, so only server compression is sensible. When \u003ccode\u003e-Xstream\u003c/code\u003e, which is the default, is used, server-side compression will not be applied to the WAL. To compress the WAL, use client-side compression, or specify \u003ccode\u003e-Xfetch\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe compression method can be set to \u003ccode\u003egzip\u003c/code\u003e, \u003ccode\u003elz4\u003c/code\u003e, \u003ccode\u003ezstd\u003c/code\u003e, \u003ccode\u003enone\u003c/code\u003e for no compression or an integer (no compression if 0, \u003ccode\u003egzip\u003c/code\u003e if greater than 0). A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form \u003cem\u003e\u003ccode\u003ekeyword\u003c/code\u003e\u003c/em\u003e or \u003cem\u003e\u003ccode\u003ekeyword=value\u003c/code\u003e\u003c/em\u003e. Currently, the supported keywords are \u003ccode\u003elevel\u003c/code\u003e, \u003ccode\u003elong\u003c/code\u003e, and \u003ccode\u003eworkers\u003c/code\u003e. The detail string cannot be used when the compression method is specified as a plain integer.\u003c/p\u003e\n\u003cp\u003eIf no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, \u003ccode\u003egzip\u003c/code\u003e compression will be used if the level is greater than 0, and no compression will be used if the level is 0.\u003c/p\u003e\n\u003cp\u003eWhen the tar format is used with \u003ccode\u003egzip\u003c/code\u003e, \u003ccode\u003elz4\u003c/code\u003e, or \u003ccode\u003ezstd\u003c/code\u003e, the suffix \u003ccode\u003e.gz\u003c/code\u003e, \u003ccode\u003e.lz4\u003c/code\u003e, or \u003ccode\u003e.zst\u003c/code\u003e, respectively, will be automatically added to all tar filenames. When the plain format is used, client-side compression may not be specified, but it is still possible to request server-side compression. If this is done, the server will compress the backup for transmission, and the client will decompress and extract it.\u003c/p\u003e\n\u003cp\u003eWhen this option is used in combination with \u003ccode\u003e-Xstream\u003c/code\u003e, \u003ccode\u003epg_wal.tar\u003c/code\u003e will be compressed using \u003ccode\u003egzip\u003c/code\u003e if client-side gzip compression is selected, but will not be compressed if any other compression algorithm is selected, or if server-side compression is selected.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following command-line options control the generation of the backup and the invocation of the program:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-c {fast|spread}\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--checkpoint={fast|spread}\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets checkpoint mode to fast (immediate) or spread (the default) (see \u003ca href=\"/docs/18/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" rel=\"nofollow\"\u003eSection 25.3.4\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-C\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--create-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies that the replication slot named by the \u003ccode\u003e--slot\u003c/code\u003e option should be created before starting the backup. An error is raised if the slot already exists.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-l \u003cem\u003e\u003ccode\u003elabel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--label=\u003cem\u003e\u003ccode\u003elabel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the label for the backup. If none is specified, a default value of \u003cspan\u003e“\u003cspan\u003e\u003ccode\u003epg_basebackup base backup\u003c/code\u003e\u003c/span\u003e”\u003c/span\u003e will be used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-clean\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, when \u003ccode\u003epg_basebackup\u003c/code\u003e aborts with an error, it removes any directories it might have created before discovering that it cannot finish the job (for example, the target directory and write-ahead log directory). This option inhibits tidying-up and is thus useful for debugging.\u003c/p\u003e\n\u003cp\u003eNote that tablespace directories are not cleaned up either way.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-N\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-sync\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode\u003epg_basebackup\u003c/code\u003e will wait for all files to be written safely to disk. This option causes \u003ccode\u003epg_basebackup\u003c/code\u003e to return without waiting, which is faster, but means that a subsequent operating system crash can leave the base backup corrupt. Generally, this option is useful for testing but should not be used when creating a production installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-P\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--progress\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables progress reporting. Turning this on will deliver an approximate progress report during the backup. Since the database may change during the backup, this is only an approximation and may not end at exactly \u003ccode\u003e100%\u003c/code\u003e. In particular, when WAL log is included in the backup, the total amount of data cannot be estimated in advance, and in this case the estimated target size will increase once it passes the total estimate without WAL.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-r \u003cem\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--max-rate=\u003cem\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the maximum transfer rate at which data is collected from the source server. This can be useful to limit the impact of \u003cspan\u003epg_basebackup\u003c/span\u003e on the server. Values are in kilobytes per second. Use a suffix of \u003ccode\u003eM\u003c/code\u003e to indicate megabytes per second. A suffix of \u003ccode\u003ek\u003c/code\u003e is also accepted, and has no effect. Valid values are between 32 kilobytes per second and 1024 megabytes per second.\u003c/p\u003e\n\u003cp\u003eThis option always affects transfer of the data directory. Transfer of WAL files is only affected if the collection method is \u003ccode\u003efetch\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-S \u003cem\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--slot=\u003cem\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option can only be used together with \u003ccode\u003e-X stream\u003c/code\u003e. It causes WAL streaming to use the specified replication slot. If the base backup is intended to be used as a streaming-replication standby using a replication slot, the standby should then use the same replication slot name as \u003ca href=\"/docs/18/runtime-config-replication.html#GUC-PRIMARY-SLOT-NAME\" rel=\"nofollow\"\u003eprimary_slot_name\u003c/a\u003e. This ensures that the primary server does not remove any necessary WAL data in the time between the end of the base backup and the start of streaming replication on the new standby.\u003c/p\u003e\n\u003cp\u003eThe specified replication slot has to exist unless the option \u003ccode\u003e-C\u003c/code\u003e is also used.\u003c/p\u003e\n\u003cp\u003eIf this option is not specified and the server supports temporary replication slots (version 10 and later), then a temporary replication slot is automatically used for WAL streaming.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--sync-method=\u003cem\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen set to \u003ccode\u003efsync\u003c/code\u003e, which is the default, \u003ccode\u003epg_basebackup\u003c/code\u003e will recursively open and synchronize all files in the backup directory. When the plain format is used, the search for files will follow symbolic links for the WAL directory and each configured tablespace.\u003c/p\u003e\n\u003cp\u003eOn Linux, \u003ccode\u003esyncfs\u003c/code\u003e may be used instead to ask the operating system to synchronize the whole file system that contains the backup directory. When the plain format is used, \u003ccode\u003epg_basebackup\u003c/code\u003e will also synchronize the file systems that contain the WAL files and each tablespace. See \u003ca href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\" rel=\"nofollow\"\u003erecovery_init_sync_method\u003c/a\u003e for information about the caveats to be aware of when using \u003ccode\u003esyncfs\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option has no effect when \u003ccode\u003e--no-sync\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--verbose\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables verbose mode. Will output some extra steps during startup and shutdown, as well as show the exact file name that is currently being processed if progress reporting is also enabled.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--manifest-checksums=\u003cem\u003e\u003ccode\u003ealgorithm\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the checksum algorithm that should be applied to each file included in the backup manifest. Currently, the available algorithms are \u003ccode\u003eNONE\u003c/code\u003e, \u003ccode\u003eCRC32C\u003c/code\u003e, \u003ccode\u003eSHA224\u003c/code\u003e, \u003ccode\u003eSHA256\u003c/code\u003e, \u003ccode\u003eSHA384\u003c/code\u003e, and \u003ccode\u003eSHA512\u003c/code\u003e. The default is \u003ccode\u003eCRC32C\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode\u003eNONE\u003c/code\u003e is selected, the backup manifest will not contain any checksums. Otherwise, it will contain a checksum of each file in the backup using the specified algorithm. In addition, the manifest will always contain a \u003ccode\u003eSHA256\u003c/code\u003e checksum of its own contents. The \u003ccode\u003eSHA\u003c/code\u003e algorithms are significantly more CPU-intensive than \u003ccode\u003eCRC32C\u003c/code\u003e, so selecting one of them may increase the time required to complete the backup.\u003c/p\u003e\n\u003cp\u003eUsing a SHA hash function provides a cryptographically secure digest of each file for users who wish to verify that the backup has not been tampered with, while the CRC-32C algorithm provides a checksum that is much faster to calculate; it is good at catching errors due to accidental changes but is not resistant to malicious modifications. Note that, to be useful against an adversary who has access to the backup, the backup manifest would need to be stored securely elsewhere or otherwise verified not to have been modified since the backup was taken.\u003c/p\u003e\n\u003cp\u003e\u003ca href=\"/docs/18/app-pgverifybackup.html\" title=\"pg_verifybackup\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_verifybackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e can be used to check the integrity of a backup against the backup manifest.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--manifest-force-encode\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForces all filenames in the backup manifest to be hex-encoded. If this option is not specified, only non-UTF8 filenames are hex-encoded. This option is mostly intended to test that tools which read a backup manifest file properly handle this case.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-estimate-size\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrevents the server from estimating the total amount of backup data that will be streamed, resulting in the \u003ccode\u003ebackup_total\u003c/code\u003e column in the \u003ccode\u003epg_stat_progress_basebackup\u003c/code\u003e view always being \u003ccode\u003eNULL\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWithout this option, the backup will start by enumerating the size of the entire database, and then go back and send the actual contents. This may make the backup take slightly longer, and in particular it will take longer before the first data is sent. This option is useful to avoid such estimation time if it\u0026#39;s too long.\u003c/p\u003e\n\u003cp\u003eThis option is not allowed when using \u003ccode\u003e--progress\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-manifest\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDisables generation of a backup manifest. If this option is not specified, the server will generate and send a backup manifest which can be verified using \u003ca href=\"/docs/18/app-pgverifybackup.html\" title=\"pg_verifybackup\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_verifybackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e. The manifest is a list of every file present in the backup with the exception of any WAL files that may be included. It also stores the size, last modification time, and an optional checksum for each file.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrevents the creation of a temporary replication slot for the backup.\u003c/p\u003e\n\u003cp\u003eBy default, if log streaming is selected but no slot name is given with the \u003ccode\u003e-S\u003c/code\u003e option, then a temporary replication slot is created (if supported by the source server).\u003c/p\u003e\n\u003cp\u003eThe main purpose of this option is to allow taking a base backup when the server has no free replication slots. Using a replication slot is almost always preferred, because it prevents needed WAL from being removed by the server during the backup.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e--no-verify-checksums\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDisables verification of checksums, if they are enabled on the server the base backup is taken from.\u003c/p\u003e\n\u003cp\u003eBy default, checksums are verified and checksum failures will result in a non-zero exit status. However, the base backup will not be removed in such a case, as if the \u003ccode\u003e--no-clean\u003c/code\u003e option had been used. Checksum verification failures will also be reported in the \u003ca href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW\" rel=\"nofollow\"\u003e\u003ccode\u003epg_stat_database\u003c/code\u003e\u003c/a\u003e view.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following command-line options control the connection to the source server:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-d \u003cem\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--dbname=\u003cem\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies parameters used to connect to the server, as a \u003ca href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" rel=\"nofollow\"\u003econnection string\u003c/a\u003e; these will override any conflicting command line options.\u003c/p\u003e\n\u003cp\u003eThis option is called \u003ccode\u003e--dbname\u003c/code\u003e for consistency with other client applications, but because \u003cspan\u003epg_basebackup\u003c/span\u003e doesn\u0026#39;t connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name (\u003ccode\u003ereplication\u003c/code\u003e) for purposes of looking up the replication connection\u0026#39;s password in \u003ccode\u003e~/.pgpass\u003c/code\u003e. Similarly, middleware or proxies used in connecting to \u003cspan\u003ePostgreSQL\u003c/span\u003e might utilize the name for purposes such as connection routing. The database name can also be used by \u003ca href=\"/docs/18/logicaldecoding-explanation.html#LOGICALDECODING-REPLICATION-SLOTS-SYNCHRONIZATION\" rel=\"nofollow\"\u003elogical replication slot synchronization\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-h \u003cem\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--host=\u003cem\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for a Unix domain socket. The default is taken from the \u003ccode\u003ePGHOST\u003c/code\u003e environment variable, if set, else a Unix domain socket connection is attempted.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-p \u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--port=\u003cem\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the \u003ccode\u003ePGPORT\u003c/code\u003e environment variable, if set, or a compiled-in default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-s \u003cem\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--status-interval=\u003cem\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the number of seconds between status packets sent back to the source server. Smaller values allow more accurate monitoring of backup progress from the server. A value of zero disables periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout-based disconnects. The default value is 10 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-U \u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--username=\u003cem\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the user name to connect as.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--no-password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrevents issuing a password prompt. If the server requires password authentication and a password is not available by other means such as a \u003ccode\u003e.pgpass\u003c/code\u003e file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForces \u003cspan\u003epg_basebackup\u003c/span\u003e to prompt for a password before connecting to the source server.\u003c/p\u003e\n\u003cp\u003eThis option is never essential, since \u003cspan\u003epg_basebackup\u003c/span\u003e will automatically prompt for a password if the server demands password authentication. However, \u003cspan\u003epg_basebackup\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther options are also available:\u003c/p\u003e\n\u003cdiv\u003e\n\u003cdl\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrints the \u003cspan\u003epg_basebackup\u003c/span\u003e version and exits.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan\u003e\u003ccode\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan\u003e\u003ccode\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows help about \u003cspan\u003epg_basebackup\u003c/span\u003e command line arguments, and exits.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.10.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cp\u003eThis utility, like most other \u003cspan\u003ePostgreSQL\u003c/span\u003e utilities, uses the environment variables supported by \u003cspan\u003elibpq\u003c/span\u003e (see \u003ca href=\"/docs/18/libpq-envars.html\" rel=\"nofollow\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eThe environment variable \u003ccode\u003ePG_COLOR\u003c/code\u003e specifies whether to use color in diagnostic messages. Possible values are \u003ccode\u003ealways\u003c/code\u003e, \u003ccode\u003eauto\u003c/code\u003e and \u003ccode\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.10.8\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eAt the beginning of the backup, a checkpoint needs to be performed on the source server. This can take some time (especially if the option \u003ccode\u003e--checkpoint=fast\u003c/code\u003e is not used), during which \u003cspan\u003epg_basebackup\u003c/span\u003e will appear to be idle.\u003c/p\u003e\n\u003cp\u003eThe backup will include all files in the data directory and tablespaces, including the configuration files and any additional files placed in the directory by third parties, except certain temporary files managed by PostgreSQL and operating system files. But only regular files and directories are copied, except that symbolic links used for tablespaces are preserved. Symbolic links pointing to certain directories known to PostgreSQL are copied as empty directories. Other symbolic links and special device files are skipped. See \u003ca href=\"/docs/18/protocol-replication.html\" rel=\"nofollow\"\u003eSection 54.4\u003c/a\u003e for the precise details.\u003c/p\u003e\n\u003cp\u003eIn plain format, tablespaces will be backed up to the same path they have on the source server, unless the option \u003ccode\u003e--tablespace-mapping\u003c/code\u003e is used. Without this option, running a plain format base backup on the same host as the server will not work if tablespaces are in use, because the backup would have to be written to the same directory locations as the original tablespaces.\u003c/p\u003e\n\u003cp\u003eWhen tar format is used, it is the user\u0026#39;s responsibility to unpack each tar file before starting a PostgreSQL server that uses the data. If there are additional tablespaces, the tar files for them need to be unpacked in the correct locations. In this case the symbolic links for those tablespaces will be created by the server according to the contents of the \u003ccode\u003etablespace_map\u003c/code\u003e file that is included in the \u003ccode\u003ebase.tar\u003c/code\u003e file.\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003epg_basebackup\u003c/span\u003e works with servers of the same or older major version, down to 9.1. However, WAL streaming mode (\u003ccode\u003e-X stream\u003c/code\u003e) only works with server version 9.3 and later, the tar format (\u003ccode\u003e--format=tar\u003c/code\u003e) only works with server version 9.5 and later, and incremental backup (\u003ccode\u003e--incremental\u003c/code\u003e) only works with server version 17 and later.\u003c/p\u003e\n\u003cp\u003e\u003cspan\u003epg_basebackup\u003c/span\u003e will preserve group permissions for data files if group permissions are enabled on the source cluster.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.10.9\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eTo create a base backup of the server at \u003ccode\u003emydbserver\u003c/code\u003e and store it in the local directory \u003ccode\u003e/usr/local/pgsql/data\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_basebackup -h mydbserver -D /usr/local/pgsql/data\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo create a backup of the local server with one compressed tar file for each tablespace, and store it in the directory \u003ccode\u003ebackup\u003c/code\u003e, showing a progress report while running:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_basebackup -D backup -Ft -z -P\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo create a backup of a single-tablespace local database and compress this with \u003cspan\u003ebzip2\u003c/span\u003e:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_basebackup -D - -Ft -X fetch | bzip2 \u0026gt; backup.tar.bz2\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003e(This command will fail if there are multiple tablespaces in the database.)\u003c/p\u003e\n\u003cp\u003eTo create a backup of a local database where the tablespace in \u003ccode\u003e/opt/ts\u003c/code\u003e is relocated to \u003ccode\u003e./backup/ts\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_basebackup -D backup/data -T /opt/ts=$(pwd)/backup/ts\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo create a backup of the local server with one tar file for each tablespace compressed with \u003cspan\u003egzip\u003c/span\u003e at level 9, stored in the directory \u003ccode\u003ebackup\u003c/code\u003e:\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003e$\u003c/code\u003e \u003cstrong\u003e\u003ccode\u003epg_basebackup -D backup -Ft --compress=gzip:9\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv id=\"id-1.9.4.10.10\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan\u003e\u003ca href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\" rel=\"nofollow\"\u003e\u003cspan\u003e\u003cspan\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca href=\"/docs/18/progress-reporting.html#BASEBACKUP-PROGRESS-REPORTING\" rel=\"nofollow\"\u003eSection 27.4.6\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","SourceRevision":"ee8d1a3612338fd9adf250730cb640fcc5233b5491337cc00a316a44e3a0b9f8","ContentHash":"9456e3de2a21da905c86a0b80b6fb120d1c9e760a2292d75aa91bece284df9de","Payload":{"description":["pg_basebackup — take a base backup of a PostgreSQL cluster"],"manual_html":"\u003cdiv\u003e\u003cdiv class=\"refentry\" id=\"APP-PGBASEBACKUP\"\u003e\n\u003cdiv class=\"titlepage\"\u003e\u003c/div\u003e\n\u003cdiv class=\"refnamediv\"\u003e\n\u003ch2\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e\u003c/span\u003e\u003c/h2\u003e\n\u003cp\u003epg_basebackup — take a base backup of a \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e cluster\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsynopsisdiv\"\u003e\n\u003ch2\u003eSynopsis\u003c/h2\u003e\n\u003cdiv class=\"cmdsynopsis\"\u003e\n\u003cp id=\"id-1.9.4.10.4.1\"\u003e\u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e [\u003cem class=\"replaceable\"\u003e\u003ccode\u003eoption\u003c/code\u003e\u003c/em\u003e...]\u003c/p\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.5\"\u003e\n\u003ch2\u003eDescription\u003c/h2\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e is used to take a base backup of a running \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e database cluster. The backup is taken without affecting other clients of the database, and can be used both for point-in-time recovery (see \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html\" title=\"25.3. Continuous Archiving and Point-in-Time Recovery (PITR)\"\u003eSection 25.3\u003c/a\u003e) and as the starting point for a log-shipping or streaming-replication standby server (see \u003ca class=\"xref\" href=\"/docs/18/warm-standby.html\" title=\"26.2. Log-Shipping Standby Servers\"\u003eSection 26.2\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e can take a full or incremental base backup of the database. When used to take a full backup, it makes an exact copy of the database cluster's files. When used to take an incremental backup, some files that would have been part of a full backup may be replaced with incremental versions of the same files, containing only those blocks that have been modified since the reference backup. An incremental backup cannot be used directly; instead, \u003ca class=\"xref\" href=\"/docs/18/app-pgcombinebackup.html\" title=\"pg_combinebackup\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_combinebackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e must first be used to combine it with the previous backups upon which it depends. See \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html#BACKUP-INCREMENTAL-BACKUP\" title=\"25.3.3. Making an Incremental Backup\"\u003eSection 25.3.3\u003c/a\u003e for more information about incremental backups, and \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html#BACKUP-PITR-RECOVERY\" title=\"25.3.5. Recovering Using a Continuous Archive Backup\"\u003eSection 25.3.5\u003c/a\u003e for steps to recover from a backup.\u003c/p\u003e\n\u003cp\u003eIn any mode, \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e makes sure the server is put into and out of backup mode automatically. Backups are always taken of the entire database cluster; it is not possible to back up individual databases or database objects. For selective backups, another tool such as \u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e must be used.\u003c/p\u003e\n\u003cp\u003eThe backup is made over a regular \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e connection that uses the replication protocol. The connection must be made with a user ID that has \u003ccode class=\"literal\"\u003eREPLICATION\u003c/code\u003e permissions (see \u003ca class=\"xref\" href=\"/docs/18/role-attributes.html\" title=\"21.2. Role Attributes\"\u003eSection 21.2\u003c/a\u003e) or is a superuser, and \u003ca class=\"link\" href=\"/docs/18/auth-pg-hba-conf.html\" title=\"20.1. The pg_hba.conf File\"\u003e\u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e\u003c/a\u003e must permit the replication connection. The server must also be configured with \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-MAX-WAL-SENDERS\"\u003emax_wal_senders\u003c/a\u003e set high enough to provide at least one walsender for the backup plus one for WAL streaming (if used).\u003c/p\u003e\n\u003cp\u003eThere can be multiple \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003es running at the same time, but it is usually better from a performance point of view to take only one backup, and copy the result.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e can make a base backup from not only a primary server but also a standby. To take a backup from a standby, set up the standby so that it can accept replication connections (that is, set \u003ccode class=\"varname\"\u003emax_wal_senders\u003c/code\u003e and \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-HOT-STANDBY\"\u003ehot_standby\u003c/a\u003e, and configure its \u003ccode class=\"filename\"\u003epg_hba.conf\u003c/code\u003e appropriately). You will also need to enable \u003ca class=\"xref\" href=\"/docs/18/runtime-config-wal.html#GUC-FULL-PAGE-WRITES\"\u003efull_page_writes\u003c/a\u003e on the primary.\u003c/p\u003e\n\u003cp\u003eNote that there are some limitations in taking a backup from a standby:\u003c/p\u003e\n\u003cdiv class=\"itemizedlist\"\u003e\n\u003cul class=\"itemizedlist\"\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eThe backup history file is not created in the database cluster backed up.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e cannot force the standby to switch to a new WAL file at the end of backup. When you are using \u003ccode class=\"literal\"\u003e-X none\u003c/code\u003e, if write activity on the primary is low, \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e may need to wait a long time for the last WAL file required for the backup to be switched and archived. In this case, it may be useful to run \u003ccode class=\"function\"\u003epg_switch_wal\u003c/code\u003e on the primary in order to trigger an immediate WAL file switch.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eIf the standby is promoted to be primary during backup, the backup fails.\u003c/p\u003e\n\u003c/li\u003e\n\u003cli class=\"listitem\"\u003e\n\u003cp\u003eAll WAL records required for the backup must contain sufficient full-page writes, which requires you to enable \u003ccode class=\"varname\"\u003efull_page_writes\u003c/code\u003e on the primary.\u003c/p\u003e\n\u003c/li\u003e\n\u003c/ul\u003e\n\u003c/div\u003e\n\u003cp\u003eWhenever \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e is taking a base backup, the server's \u003ccode class=\"structname\"\u003epg_stat_progress_basebackup\u003c/code\u003e view will report the progress of the backup. See \u003ca class=\"xref\" href=\"/docs/18/progress-reporting.html#BASEBACKUP-PROGRESS-REPORTING\" title=\"27.4.6. Base Backup Progress Reporting\"\u003eSection 27.4.6\u003c/a\u003e for details.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.6\"\u003e\n\u003ch2\u003eOptions\u003c/h2\u003e\n\u003cp\u003eThe following command-line options control the location and format of the output:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-D \u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--pgdata=\u003cem class=\"replaceable\"\u003e\u003ccode\u003edirectory\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the target directory to write the output to. \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will create this directory (and any missing parent directories) if it does not exist. If it already exists, it must be empty.\u003c/p\u003e\n\u003cp\u003eWhen the backup is in tar format, the target directory may be specified as \u003ccode class=\"literal\"\u003e-\u003c/code\u003e (dash), causing the tar file to be written to \u003ccode class=\"literal\"\u003estdout\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option is required.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-F \u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--format=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSelects the format for the output. \u003cem class=\"replaceable\"\u003e\u003ccode\u003eformat\u003c/code\u003e\u003c/em\u003e can be one of the following:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ep\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003eplain\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite the output as plain files, with the same layout as the source server's data directory and tablespaces. When the cluster has no additional tablespaces, the whole database will be placed in the target directory. If the cluster contains additional tablespaces, the main data directory will be placed in the target directory, but all other tablespaces will be placed in the same absolute path as they have on the source server. (See \u003ccode class=\"option\"\u003e--tablespace-mapping\u003c/code\u003e to change that.)\u003c/p\u003e\n\u003cp\u003eThis is the default format.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003et\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003etar\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWrite the output as tar files in the target directory. The main data directory's contents will be written to a file named \u003ccode class=\"filename\"\u003ebase.tar\u003c/code\u003e, and each other tablespace will be written to a separate tar file named after that tablespace's OID.\u003c/p\u003e\n\u003cp\u003eIf the target directory is specified as \u003ccode class=\"literal\"\u003e-\u003c/code\u003e (dash), the tar contents will be written to standard output, suitable for piping to (for example) \u003cspan class=\"productname\"\u003egzip\u003c/span\u003e. This is only allowed if the cluster has no additional tablespaces and WAL streaming is not used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-i \u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_manifest_file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--incremental=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eold_manifest_file\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePerforms an \u003ca class=\"link\" href=\"/docs/18/continuous-archiving.html#BACKUP-INCREMENTAL-BACKUP\" title=\"25.3.3. Making an Incremental Backup\"\u003eincremental backup\u003c/a\u003e. The backup manifest for the reference backup must be provided, and will be uploaded to the server, which will respond by sending the requested incremental backup.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-R\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--write-recovery-conf\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eCreates a \u003ca class=\"link\" href=\"/docs/18/warm-standby.html#FILE-STANDBY-SIGNAL\"\u003e\u003ccode class=\"filename\"\u003estandby.signal\u003c/code\u003e\u003c/a\u003e  file and appends connection settings to the \u003ccode class=\"filename\"\u003epostgresql.auto.conf\u003c/code\u003e file in the target directory (or within the base archive file when using tar format). This eases setting up a standby server using the results of the backup.\u003c/p\u003e\n\u003cp\u003eThe \u003ccode class=\"filename\"\u003epostgresql.auto.conf\u003c/code\u003e file will record the connection settings and, if specified, the replication slot that \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e is using, so that streaming replication and \u003ca class=\"link\" href=\"/docs/18/logicaldecoding-explanation.html#LOGICALDECODING-REPLICATION-SLOTS-SYNCHRONIZATION\" title=\"47.2.3. Replication Slot Synchronization\"\u003elogical replication slot synchronization\u003c/a\u003e will use the same settings later on. The dbname will be recorded only if the dbname was specified explicitly in the connection string or \u003ca class=\"link\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eenvironment variable\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-t \u003cem class=\"replaceable\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--target=\u003cem class=\"replaceable\"\u003e\u003ccode\u003etarget\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eInstructs the server where to place the base backup. The default target is \u003ccode class=\"literal\"\u003eclient\u003c/code\u003e, which specifies that the backup should be sent to the machine where \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e is running. If the target is instead set to \u003ccode class=\"literal\"\u003eserver:/some/path\u003c/code\u003e, the backup will be stored on the machine where the server is running in the \u003ccode class=\"literal\"\u003e/some/path\u003c/code\u003e directory. Storing a backup on the server requires superuser privileges or having privileges of the \u003ccode class=\"literal\"\u003epg_write_server_files\u003c/code\u003e role. If the target is set to \u003ccode class=\"literal\"\u003eblackhole\u003c/code\u003e, the contents are discarded and not stored anywhere. This should only be used for testing purposes, as you will not end up with an actual backup.\u003c/p\u003e\n\u003cp\u003eSince WAL streaming is implemented by \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e rather than by the server, this option cannot be used together with \u003ccode class=\"literal\"\u003e-Xstream\u003c/code\u003e. Since that is the default, when this option is specified, you must also specify either \u003ccode class=\"literal\"\u003e-Xfetch\u003c/code\u003e or \u003ccode class=\"literal\"\u003e-Xnone\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-T \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--tablespace-mapping=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e=\u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRelocates the tablespace in directory \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e to \u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e during the backup. To be effective, \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e must exactly match the path specification of the tablespace as it is defined on the source server. (But it is not an error if there is no tablespace in \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e on the source server.) Meanwhile \u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e is a directory in the receiving host's filesystem. As with the main target directory, \u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e need not exist already, but if it does exist it must be empty. Both \u003cem class=\"replaceable\"\u003e\u003ccode\u003eolddir\u003c/code\u003e\u003c/em\u003e and \u003cem class=\"replaceable\"\u003e\u003ccode\u003enewdir\u003c/code\u003e\u003c/em\u003e must be absolute paths. If either path needs to contain an equal sign (\u003ccode class=\"literal\"\u003e=\u003c/code\u003e), precede that with a backslash. This option can be specified multiple times for multiple tablespaces.\u003c/p\u003e\n\u003cp\u003eIf a tablespace is relocated in this way, the symbolic links inside the main data directory are updated to point to the new location. So the new data directory is ready to be used for a new server instance with all tablespaces in the updated locations.\u003c/p\u003e\n\u003cp\u003eCurrently, this option only works with plain output format; it is ignored if tar format is selected.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--waldir=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ewaldir\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the directory to write WAL (write-ahead log) files to. By default WAL files will be placed in the \u003ccode class=\"filename\"\u003epg_wal\u003c/code\u003e subdirectory of the target directory, but this option can be used to place them elsewhere. \u003cem class=\"replaceable\"\u003e\u003ccode\u003ewaldir\u003c/code\u003e\u003c/em\u003e must be an absolute path. As with the main target directory, \u003cem class=\"replaceable\"\u003e\u003ccode\u003ewaldir\u003c/code\u003e\u003c/em\u003e need not exist already, but if it does exist it must be empty. This option can only be specified when the backup is in plain format.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-X \u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--wal-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eIncludes the required WAL (write-ahead log) files in the backup. This will include all write-ahead logs generated during the backup. Unless the method \u003ccode class=\"literal\"\u003enone\u003c/code\u003e is specified, it is possible to start a postmaster in the target directory without the need to consult the WAL archive, thus making the output a completely standalone backup.\u003c/p\u003e\n\u003cp\u003eThe following \u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003es for collecting the write-ahead logs are supported:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003en\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003enone\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDon't include write-ahead logs in the backup.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003ef\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003efetch\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThe write-ahead log files are collected at the end of the backup. Therefore, it is necessary for the source server's \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-WAL-KEEP-SIZE\"\u003ewal_keep_size\u003c/a\u003e parameter to be set high enough that the required log data is not removed before the end of the backup. If the required log data has been recycled before it's time to transfer it, the backup will fail and be unusable.\u003c/p\u003e\n\u003cp\u003eWhen tar format is used, the write-ahead log files will be included in the \u003ccode class=\"filename\"\u003ebase.tar\u003c/code\u003e file.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003es\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"literal\"\u003estream\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eStream write-ahead log data while the backup is being taken. This method will open a second connection to the server and start streaming the write-ahead log in parallel while running the backup. Therefore, it will require two replication connections not just one. As long as the client can keep up with the write-ahead log data, using this method requires no extra write-ahead logs to be saved on the source server.\u003c/p\u003e\n\u003cp\u003eWhen tar format is used, the write-ahead log files will be written to a separate file named \u003ccode class=\"filename\"\u003epg_wal.tar\u003c/code\u003e (if the server is a version earlier than 10, the file will be named \u003ccode class=\"filename\"\u003epg_xlog.tar\u003c/code\u003e).\u003c/p\u003e\n\u003cp\u003eThis value is the default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-z\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--gzip\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables gzip compression of tar file output, with the default compression level. Compression is only available when using the tar format, and the suffix \u003ccode class=\"filename\"\u003e.gz\u003c/code\u003e will automatically be added to all tar filenames.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-Z \u003cem class=\"replaceable\"\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-Z [{client|server}-]\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem class=\"replaceable\"\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--compress=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elevel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--compress=[{client|server}-]\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e[:\u003cem class=\"replaceable\"\u003e\u003ccode\u003edetail\u003c/code\u003e\u003c/em\u003e]\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eRequests compression of the backup. If \u003ccode class=\"literal\"\u003eclient\u003c/code\u003e or \u003ccode class=\"literal\"\u003eserver\u003c/code\u003e is included, it specifies where the compression is to be performed. Compressing on the server will reduce transfer bandwidth but will increase server CPU consumption. The default is \u003ccode class=\"literal\"\u003eclient\u003c/code\u003e except when \u003ccode class=\"literal\"\u003e--target\u003c/code\u003e is used. In that case, the backup is not being sent to the client, so only server compression is sensible. When \u003ccode class=\"literal\"\u003e-Xstream\u003c/code\u003e, which is the default, is used, server-side compression will not be applied to the WAL. To compress the WAL, use client-side compression, or specify \u003ccode class=\"literal\"\u003e-Xfetch\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThe compression method can be set to \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e, \u003ccode class=\"literal\"\u003elz4\u003c/code\u003e, \u003ccode class=\"literal\"\u003ezstd\u003c/code\u003e, \u003ccode class=\"literal\"\u003enone\u003c/code\u003e for no compression or an integer (no compression if 0, \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e if greater than 0). A compression detail string can optionally be specified. If the detail string is an integer, it specifies the compression level. Otherwise, it should be a comma-separated list of items, each of the form \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword\u003c/code\u003e\u003c/em\u003e or \u003cem class=\"replaceable\"\u003e\u003ccode\u003ekeyword=value\u003c/code\u003e\u003c/em\u003e. Currently, the supported keywords are \u003ccode class=\"literal\"\u003elevel\u003c/code\u003e, \u003ccode class=\"literal\"\u003elong\u003c/code\u003e, and \u003ccode class=\"literal\"\u003eworkers\u003c/code\u003e. The detail string cannot be used when the compression method is specified as a plain integer.\u003c/p\u003e\n\u003cp\u003eIf no compression level is specified, the default compression level will be used. If only a level is specified without mentioning an algorithm, \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e compression will be used if the level is greater than 0, and no compression will be used if the level is 0.\u003c/p\u003e\n\u003cp\u003eWhen the tar format is used with \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e, \u003ccode class=\"literal\"\u003elz4\u003c/code\u003e, or \u003ccode class=\"literal\"\u003ezstd\u003c/code\u003e, the suffix \u003ccode class=\"filename\"\u003e.gz\u003c/code\u003e, \u003ccode class=\"filename\"\u003e.lz4\u003c/code\u003e, or \u003ccode class=\"filename\"\u003e.zst\u003c/code\u003e, respectively, will be automatically added to all tar filenames. When the plain format is used, client-side compression may not be specified, but it is still possible to request server-side compression. If this is done, the server will compress the backup for transmission, and the client will decompress and extract it.\u003c/p\u003e\n\u003cp\u003eWhen this option is used in combination with \u003ccode class=\"literal\"\u003e-Xstream\u003c/code\u003e, \u003ccode class=\"literal\"\u003epg_wal.tar\u003c/code\u003e will be compressed using \u003ccode class=\"literal\"\u003egzip\u003c/code\u003e if client-side gzip compression is selected, but will not be compressed if any other compression algorithm is selected, or if server-side compression is selected.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following command-line options control the generation of the backup and the invocation of the program:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-c {fast|spread}\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--checkpoint={fast|spread}\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets checkpoint mode to fast (immediate) or spread (the default) (see \u003ca class=\"xref\" href=\"/docs/18/continuous-archiving.html#BACKUP-LOWLEVEL-BASE-BACKUP\" title=\"25.3.4. Making a Base Backup Using the Low Level API\"\u003eSection 25.3.4\u003c/a\u003e).\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-C\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--create-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies that the replication slot named by the \u003ccode class=\"literal\"\u003e--slot\u003c/code\u003e option should be created before starting the backup. An error is raised if the slot already exists.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-l \u003cem class=\"replaceable\"\u003e\u003ccode\u003elabel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--label=\u003cem class=\"replaceable\"\u003e\u003ccode\u003elabel\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the label for the backup. If none is specified, a default value of \u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003e\u003ccode class=\"literal\"\u003epg_basebackup base backup\u003c/code\u003e\u003c/span\u003e”\u003c/span\u003e will be used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-n\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-clean\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, when \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e aborts with an error, it removes any directories it might have created before discovering that it cannot finish the job (for example, the target directory and write-ahead log directory). This option inhibits tidying-up and is thus useful for debugging.\u003c/p\u003e\n\u003cp\u003eNote that tablespace directories are not cleaned up either way.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-N\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eBy default, \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e will wait for all files to be written safely to disk. This option causes \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e to return without waiting, which is faster, but means that a subsequent operating system crash can leave the base backup corrupt. Generally, this option is useful for testing but should not be used when creating a production installation.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-P\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--progress\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables progress reporting. Turning this on will deliver an approximate progress report during the backup. Since the database may change during the backup, this is only an approximation and may not end at exactly \u003ccode class=\"literal\"\u003e100%\u003c/code\u003e. In particular, when WAL log is included in the backup, the total amount of data cannot be estimated in advance, and in this case the estimated target size will increase once it passes the total estimate without WAL.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-r \u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--max-rate=\u003cem class=\"replaceable\"\u003e\u003ccode\u003erate\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSets the maximum transfer rate at which data is collected from the source server. This can be useful to limit the impact of \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e on the server. Values are in kilobytes per second. Use a suffix of \u003ccode class=\"literal\"\u003eM\u003c/code\u003e to indicate megabytes per second. A suffix of \u003ccode class=\"literal\"\u003ek\u003c/code\u003e is also accepted, and has no effect. Valid values are between 32 kilobytes per second and 1024 megabytes per second.\u003c/p\u003e\n\u003cp\u003eThis option always affects transfer of the data directory. Transfer of WAL files is only affected if the collection method is \u003ccode class=\"literal\"\u003efetch\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-S \u003cem class=\"replaceable\"\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--slot=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eslotname\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eThis option can only be used together with \u003ccode class=\"literal\"\u003e-X stream\u003c/code\u003e. It causes WAL streaming to use the specified replication slot. If the base backup is intended to be used as a streaming-replication standby using a replication slot, the standby should then use the same replication slot name as \u003ca class=\"xref\" href=\"/docs/18/runtime-config-replication.html#GUC-PRIMARY-SLOT-NAME\"\u003eprimary_slot_name\u003c/a\u003e. This ensures that the primary server does not remove any necessary WAL data in the time between the end of the base backup and the start of streaming replication on the new standby.\u003c/p\u003e\n\u003cp\u003eThe specified replication slot has to exist unless the option \u003ccode class=\"option\"\u003e-C\u003c/code\u003e is also used.\u003c/p\u003e\n\u003cp\u003eIf this option is not specified and the server supports temporary replication slots (version 10 and later), then a temporary replication slot is automatically used for WAL streaming.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--sync-method=\u003cem class=\"replaceable\"\u003e\u003ccode\u003emethod\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eWhen set to \u003ccode class=\"literal\"\u003efsync\u003c/code\u003e, which is the default, \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e will recursively open and synchronize all files in the backup directory. When the plain format is used, the search for files will follow symbolic links for the WAL directory and each configured tablespace.\u003c/p\u003e\n\u003cp\u003eOn Linux, \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e may be used instead to ask the operating system to synchronize the whole file system that contains the backup directory. When the plain format is used, \u003ccode class=\"command\"\u003epg_basebackup\u003c/code\u003e will also synchronize the file systems that contain the WAL files and each tablespace. See \u003ca class=\"xref\" href=\"/docs/18/runtime-config-error-handling.html#GUC-RECOVERY-INIT-SYNC-METHOD\"\u003erecovery_init_sync_method\u003c/a\u003e for information about the caveats to be aware of when using \u003ccode class=\"literal\"\u003esyncfs\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eThis option has no effect when \u003ccode class=\"option\"\u003e--no-sync\u003c/code\u003e is used.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-v\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--verbose\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eEnables verbose mode. Will output some extra steps during startup and shutdown, as well as show the exact file name that is currently being processed if progress reporting is also enabled.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--manifest-checksums=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ealgorithm\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the checksum algorithm that should be applied to each file included in the backup manifest. Currently, the available algorithms are \u003ccode class=\"literal\"\u003eNONE\u003c/code\u003e, \u003ccode class=\"literal\"\u003eCRC32C\u003c/code\u003e, \u003ccode class=\"literal\"\u003eSHA224\u003c/code\u003e, \u003ccode class=\"literal\"\u003eSHA256\u003c/code\u003e, \u003ccode class=\"literal\"\u003eSHA384\u003c/code\u003e, and \u003ccode class=\"literal\"\u003eSHA512\u003c/code\u003e. The default is \u003ccode class=\"literal\"\u003eCRC32C\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eIf \u003ccode class=\"literal\"\u003eNONE\u003c/code\u003e is selected, the backup manifest will not contain any checksums. Otherwise, it will contain a checksum of each file in the backup using the specified algorithm. In addition, the manifest will always contain a \u003ccode class=\"literal\"\u003eSHA256\u003c/code\u003e checksum of its own contents. The \u003ccode class=\"literal\"\u003eSHA\u003c/code\u003e algorithms are significantly more CPU-intensive than \u003ccode class=\"literal\"\u003eCRC32C\u003c/code\u003e, so selecting one of them may increase the time required to complete the backup.\u003c/p\u003e\n\u003cp\u003eUsing a SHA hash function provides a cryptographically secure digest of each file for users who wish to verify that the backup has not been tampered with, while the CRC-32C algorithm provides a checksum that is much faster to calculate; it is good at catching errors due to accidental changes but is not resistant to malicious modifications. Note that, to be useful against an adversary who has access to the backup, the backup manifest would need to be stored securely elsewhere or otherwise verified not to have been modified since the backup was taken.\u003c/p\u003e\n\u003cp\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgverifybackup.html\" title=\"pg_verifybackup\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_verifybackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e can be used to check the integrity of a backup against the backup manifest.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--manifest-force-encode\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForces all filenames in the backup manifest to be hex-encoded. If this option is not specified, only non-UTF8 filenames are hex-encoded. This option is mostly intended to test that tools which read a backup manifest file properly handle this case.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-estimate-size\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrevents the server from estimating the total amount of backup data that will be streamed, resulting in the \u003ccode class=\"structfield\"\u003ebackup_total\u003c/code\u003e column in the \u003ccode class=\"structname\"\u003epg_stat_progress_basebackup\u003c/code\u003e view always being \u003ccode class=\"literal\"\u003eNULL\u003c/code\u003e.\u003c/p\u003e\n\u003cp\u003eWithout this option, the backup will start by enumerating the size of the entire database, and then go back and send the actual contents. This may make the backup take slightly longer, and in particular it will take longer before the first data is sent. This option is useful to avoid such estimation time if it's too long.\u003c/p\u003e\n\u003cp\u003eThis option is not allowed when using \u003ccode class=\"option\"\u003e--progress\u003c/code\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-manifest\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDisables generation of a backup manifest. If this option is not specified, the server will generate and send a backup manifest which can be verified using \u003ca class=\"xref\" href=\"/docs/18/app-pgverifybackup.html\" title=\"pg_verifybackup\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_verifybackup\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e. The manifest is a list of every file present in the backup with the exception of any WAL files that may be included. It also stores the size, last modification time, and an optional checksum for each file.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-slot\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrevents the creation of a temporary replication slot for the backup.\u003c/p\u003e\n\u003cp\u003eBy default, if log streaming is selected but no slot name is given with the \u003ccode class=\"option\"\u003e-S\u003c/code\u003e option, then a temporary replication slot is created (if supported by the source server).\u003c/p\u003e\n\u003cp\u003eThe main purpose of this option is to allow taking a base backup when the server has no free replication slots. Using a replication slot is almost always preferred, because it prevents needed WAL from being removed by the server during the backup.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-verify-checksums\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eDisables verification of checksums, if they are enabled on the server the base backup is taken from.\u003c/p\u003e\n\u003cp\u003eBy default, checksums are verified and checksum failures will result in a non-zero exit status. However, the base backup will not be removed in such a case, as if the \u003ccode class=\"option\"\u003e--no-clean\u003c/code\u003e option had been used. Checksum verification failures will also be reported in the \u003ca class=\"link\" href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW\" title=\"27.2.17. pg_stat_database\"\u003e\u003ccode class=\"structname\"\u003epg_stat_database\u003c/code\u003e\u003c/a\u003e view.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eThe following command-line options control the connection to the source server:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-d \u003cem class=\"replaceable\"\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--dbname=\u003cem class=\"replaceable\"\u003e\u003ccode\u003econnstr\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies parameters used to connect to the server, as a \u003ca class=\"link\" href=\"/docs/18/libpq-connect.html#LIBPQ-CONNSTRING\" title=\"32.1.1. Connection Strings\"\u003econnection string\u003c/a\u003e; these will override any conflicting command line options.\u003c/p\u003e\n\u003cp\u003eThis option is called \u003ccode class=\"literal\"\u003e--dbname\u003c/code\u003e for consistency with other client applications, but because \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e doesn't connect to any particular database in the cluster, any database name included in the connection string will be ignored by the server. However, a database name supplied that way overrides the default database name (\u003ccode class=\"literal\"\u003ereplication\u003c/code\u003e) for purposes of looking up the replication connection's password in \u003ccode class=\"filename\"\u003e~/.pgpass\u003c/code\u003e. Similarly, middleware or proxies used in connecting to \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e might utilize the name for purposes such as connection routing. The database name can also be used by \u003ca class=\"link\" href=\"/docs/18/logicaldecoding-explanation.html#LOGICALDECODING-REPLICATION-SLOTS-SYNCHRONIZATION\" title=\"47.2.3. Replication Slot Synchronization\"\u003elogical replication slot synchronization\u003c/a\u003e.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-h \u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--host=\u003cem class=\"replaceable\"\u003e\u003ccode\u003ehost\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for a Unix domain socket. The default is taken from the \u003ccode class=\"envar\"\u003ePGHOST\u003c/code\u003e environment variable, if set, else a Unix domain socket connection is attempted.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-p \u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--port=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eport\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the \u003ccode class=\"envar\"\u003ePGPORT\u003c/code\u003e environment variable, if set, or a compiled-in default.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-s \u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--status-interval=\u003cem class=\"replaceable\"\u003e\u003ccode\u003einterval\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the number of seconds between status packets sent back to the source server. Smaller values allow more accurate monitoring of backup progress from the server. A value of zero disables periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout-based disconnects. The default value is 10 seconds.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-U \u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--username=\u003cem class=\"replaceable\"\u003e\u003ccode\u003eusername\u003c/code\u003e\u003c/em\u003e\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eSpecifies the user name to connect as.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-w\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--no-password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrevents issuing a password prompt. If the server requires password authentication and a password is not available by other means such as a \u003ccode class=\"filename\"\u003e.pgpass\u003c/code\u003e file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-W\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--password\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eForces \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e to prompt for a password before connecting to the source server.\u003c/p\u003e\n\u003cp\u003eThis option is never essential, since \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will automatically prompt for a password if the server demands password authentication. However, \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing \u003ccode class=\"option\"\u003e-W\u003c/code\u003e to avoid the extra connection attempt.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003cp\u003eOther options are also available:\u003c/p\u003e\n\u003cdiv class=\"variablelist\"\u003e\n\u003cdl class=\"variablelist\"\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-V\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--version\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003ePrints the \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e version and exits.\u003c/p\u003e\n\u003c/dd\u003e\n\u003cdt\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e-?\u003c/code\u003e\u003cbr\u003e\u003c/span\u003e\u003cspan class=\"term\"\u003e\u003ccode class=\"option\"\u003e--help\u003c/code\u003e\u003c/span\u003e\u003c/dt\u003e\n\u003cdd\u003e\n\u003cp\u003eShows help about \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e command line arguments, and exits.\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\u003c/div\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.7\"\u003e\n\u003ch2\u003eEnvironment\u003c/h2\u003e\n\u003cp\u003eThis utility, like most other \u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e utilities, uses the environment variables supported by \u003cspan class=\"application\"\u003elibpq\u003c/span\u003e (see \u003ca class=\"xref\" href=\"/docs/18/libpq-envars.html\" title=\"32.15. Environment Variables\"\u003eSection 32.15\u003c/a\u003e).\u003c/p\u003e\n\u003cp\u003eThe environment variable \u003ccode class=\"envar\"\u003ePG_COLOR\u003c/code\u003e specifies whether to use color in diagnostic messages. Possible values are \u003ccode class=\"literal\"\u003ealways\u003c/code\u003e, \u003ccode class=\"literal\"\u003eauto\u003c/code\u003e and \u003ccode class=\"literal\"\u003enever\u003c/code\u003e.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.8\"\u003e\n\u003ch2\u003eNotes\u003c/h2\u003e\n\u003cp\u003eAt the beginning of the backup, a checkpoint needs to be performed on the source server. This can take some time (especially if the option \u003ccode class=\"literal\"\u003e--checkpoint=fast\u003c/code\u003e is not used), during which \u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will appear to be idle.\u003c/p\u003e\n\u003cp\u003eThe backup will include all files in the data directory and tablespaces, including the configuration files and any additional files placed in the directory by third parties, except certain temporary files managed by PostgreSQL and operating system files. But only regular files and directories are copied, except that symbolic links used for tablespaces are preserved. Symbolic links pointing to certain directories known to PostgreSQL are copied as empty directories. Other symbolic links and special device files are skipped. See \u003ca class=\"xref\" href=\"/docs/18/protocol-replication.html\" title=\"54.4. Streaming Replication Protocol\"\u003eSection 54.4\u003c/a\u003e for the precise details.\u003c/p\u003e\n\u003cp\u003eIn plain format, tablespaces will be backed up to the same path they have on the source server, unless the option \u003ccode class=\"literal\"\u003e--tablespace-mapping\u003c/code\u003e is used. Without this option, running a plain format base backup on the same host as the server will not work if tablespaces are in use, because the backup would have to be written to the same directory locations as the original tablespaces.\u003c/p\u003e\n\u003cp\u003eWhen tar format is used, it is the user's responsibility to unpack each tar file before starting a PostgreSQL server that uses the data. If there are additional tablespaces, the tar files for them need to be unpacked in the correct locations. In this case the symbolic links for those tablespaces will be created by the server according to the contents of the \u003ccode class=\"filename\"\u003etablespace_map\u003c/code\u003e file that is included in the \u003ccode class=\"filename\"\u003ebase.tar\u003c/code\u003e file.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e works with servers of the same or older major version, down to 9.1. However, WAL streaming mode (\u003ccode class=\"literal\"\u003e-X stream\u003c/code\u003e) only works with server version 9.3 and later, the tar format (\u003ccode class=\"literal\"\u003e--format=tar\u003c/code\u003e) only works with server version 9.5 and later, and incremental backup (\u003ccode class=\"literal\"\u003e--incremental\u003c/code\u003e) only works with server version 17 and later.\u003c/p\u003e\n\u003cp\u003e\u003cspan class=\"application\"\u003epg_basebackup\u003c/span\u003e will preserve group permissions for data files if group permissions are enabled on the source cluster.\u003c/p\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.9\"\u003e\n\u003ch2\u003eExamples\u003c/h2\u003e\n\u003cp\u003eTo create a base backup of the server at \u003ccode class=\"literal\"\u003emydbserver\u003c/code\u003e and store it in the local directory \u003ccode class=\"filename\"\u003e/usr/local/pgsql/data\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -h mydbserver -D /usr/local/pgsql/data\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo create a backup of the local server with one compressed tar file for each tablespace, and store it in the directory \u003ccode class=\"filename\"\u003ebackup\u003c/code\u003e, showing a progress report while running:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -D backup -Ft -z -P\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo create a backup of a single-tablespace local database and compress this with \u003cspan class=\"productname\"\u003ebzip2\u003c/span\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -D - -Ft -X fetch | bzip2 \u0026gt; backup.tar.bz2\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003e(This command will fail if there are multiple tablespaces in the database.)\u003c/p\u003e\n\u003cp\u003eTo create a backup of a local database where the tablespace in \u003ccode class=\"filename\"\u003e/opt/ts\u003c/code\u003e is relocated to \u003ccode class=\"filename\"\u003e./backup/ts\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -D backup/data -T /opt/ts=$(pwd)/backup/ts\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003cp\u003eTo create a backup of the local server with one tar file for each tablespace compressed with \u003cspan class=\"application\"\u003egzip\u003c/span\u003e at level 9, stored in the directory \u003ccode class=\"filename\"\u003ebackup\u003c/code\u003e:\u003c/p\u003e\n\u003cpre class=\"screen\"\u003e\u003ccode class=\"prompt\"\u003e$\u003c/code\u003e \u003cstrong class=\"userinput\"\u003e\u003ccode\u003epg_basebackup -D backup -Ft --compress=gzip:9\u003c/code\u003e\u003c/strong\u003e\n\u003c/pre\u003e\n\u003c/div\u003e\n\u003cdiv class=\"refsect1\" id=\"id-1.9.4.10.10\"\u003e\n\u003ch2\u003eSee Also\u003c/h2\u003e\u003cspan class=\"simplelist\"\u003e\u003ca class=\"xref\" href=\"/docs/18/app-pgdump.html\" title=\"pg_dump\"\u003e\u003cspan class=\"refentrytitle\"\u003e\u003cspan class=\"application\"\u003epg_dump\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e, \u003ca class=\"xref\" href=\"/docs/18/progress-reporting.html#BASEBACKUP-PROGRESS-REPORTING\" title=\"27.4.6. Base Backup Progress Reporting\"\u003eSection 27.4.6\u003c/a\u003e\u003c/span\u003e\n\u003c/div\u003e\n\u003c/div\u003e\u003c/div\u003e","related":[{"label":"libpq connection parameters","url":"/wiki/conn/?v=18"}],"sections":[],"tables":[{"columns":[{"key":"signature","label":"Option and arguments"},{"key":"summary","label":"Description"}],"key":"options","rows":[{"signature":{"text":"-D directory --pgdata= directory","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets the target directory to write the output to. pg_basebackup will create this directory (and any missing parent directories) if it does not exist. If it already exists, it must be empty."},{"signature":{"text":"-F format --format= format","url":"/docs/18/app-pgbasebackup.html"},"summary":"Selects the format for the output. format can be one of the following:"},{"signature":{"text":"-i old_manifest_file --incremental= old_manifest_file","url":"/docs/18/app-pgbasebackup.html"},"summary":"Performs an incremental backup . The backup manifest for the reference backup must be provided, and will be uploaded to the server, which will respond by sending the requested incremental backup."},{"signature":{"text":"-R --write-recovery-conf","url":"/docs/18/app-pgbasebackup.html"},"summary":"Creates a standby.signal file and appends connection settings to the postgresql.auto.conf file in the target directory (or within the base archive file when using tar format). This eases setting up a standby server using the results of the backup."},{"signature":{"text":"-t target --target= target","url":"/docs/18/app-pgbasebackup.html"},"summary":"Instructs the server where to place the base backup. The default target is client , which specifies that the backup should be sent to the machine where pg_basebackup is running. If the target is instead set to server:/some/path , the backup will be stored on the machine where the server is running in the /some/path directory. Storing a backup on the server requires superuser privileges or having privileges of the pg_write_server_files role. If the target is set to blackhole , the contents are discarded and not stored anywhere. This should only be used for testing purposes, as you will not end up with an actual backup."},{"signature":{"text":"-T olddir = newdir --tablespace-mapping= olddir = newdir","url":"/docs/18/app-pgbasebackup.html"},"summary":"Relocates the tablespace in directory olddir to newdir during the backup. To be effective, olddir must exactly match the path specification of the tablespace as it is defined on the source server. (But it is not an error if there is no tablespace in olddir on the source server.) Meanwhile newdir is a directory in the receiving host's filesystem. As with the main target directory, newdir need not exist already, but if it does exist it must be empty. Both olddir and newdir must be absolute paths. If either path needs to contain an equal sign ( = ), precede that with a backslash. This option can be specified multiple times for multiple tablespaces."},{"signature":{"text":"--waldir= waldir","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets the directory to write WAL (write-ahead log) files to. By default WAL files will be placed in the pg_wal subdirectory of the target directory, but this option can be used to place them elsewhere. waldir must be an absolute path. As with the main target directory, waldir need not exist already, but if it does exist it must be empty. This option can only be specified when the backup is in plain format."},{"signature":{"text":"-X method --wal-method= method","url":"/docs/18/app-pgbasebackup.html"},"summary":"Includes the required WAL (write-ahead log) files in the backup. This will include all write-ahead logs generated during the backup. Unless the method none is specified, it is possible to start a postmaster in the target directory without the need to consult the WAL archive, thus making the output a completely standalone backup."},{"signature":{"text":"-z --gzip","url":"/docs/18/app-pgbasebackup.html"},"summary":"Enables gzip compression of tar file output, with the default compression level. Compression is only available when using the tar format, and the suffix .gz will automatically be added to all tar filenames."},{"signature":{"text":"-Z level -Z [{client|server}-] method [: detail ] --compress= level --compress=[{client|server}-] method [: detail ]","url":"/docs/18/app-pgbasebackup.html"},"summary":"Requests compression of the backup. If client or server is included, it specifies where the compression is to be performed. Compressing on the server will reduce transfer bandwidth but will increase server CPU consumption. The default is client except when --target is used. In that case, the backup is not being sent to the client, so only server compression is sensible. When -Xstream , which is the default, is used, server-side compression will not be applied to the WAL. To compress the WAL, use client-side compression, or specify -Xfetch ."},{"signature":{"text":"-c {fast|spread} --checkpoint={fast|spread}","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets checkpoint mode to fast (immediate) or spread (the default) (see Section 25.3.4 )."},{"signature":{"text":"-C --create-slot","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies that the replication slot named by the --slot option should be created before starting the backup. An error is raised if the slot already exists."},{"signature":{"text":"-l label --label= label","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets the label for the backup. If none is specified, a default value of “ pg_basebackup base backup ” will be used."},{"signature":{"text":"-n --no-clean","url":"/docs/18/app-pgbasebackup.html"},"summary":"By default, when pg_basebackup aborts with an error, it removes any directories it might have created before discovering that it cannot finish the job (for example, the target directory and write-ahead log directory). This option inhibits tidying-up and is thus useful for debugging."},{"signature":{"text":"-N --no-sync","url":"/docs/18/app-pgbasebackup.html"},"summary":"By default, pg_basebackup will wait for all files to be written safely to disk. This option causes pg_basebackup to return without waiting, which is faster, but means that a subsequent operating system crash can leave the base backup corrupt. Generally, this option is useful for testing but should not be used when creating a production installation."},{"signature":{"text":"-P --progress","url":"/docs/18/app-pgbasebackup.html"},"summary":"Enables progress reporting. Turning this on will deliver an approximate progress report during the backup. Since the database may change during the backup, this is only an approximation and may not end at exactly 100% . In particular, when WAL log is included in the backup, the total amount of data cannot be estimated in advance, and in this case the estimated target size will increase once it passes the total estimate without WAL."},{"signature":{"text":"-r rate --max-rate= rate","url":"/docs/18/app-pgbasebackup.html"},"summary":"Sets the maximum transfer rate at which data is collected from the source server. This can be useful to limit the impact of pg_basebackup on the server. Values are in kilobytes per second. Use a suffix of M to indicate megabytes per second. A suffix of k is also accepted, and has no effect. Valid values are between 32 kilobytes per second and 1024 megabytes per second."},{"signature":{"text":"-S slotname --slot= slotname","url":"/docs/18/app-pgbasebackup.html"},"summary":"This option can only be used together with -X stream . It causes WAL streaming to use the specified replication slot. If the base backup is intended to be used as a streaming-replication standby using a replication slot, the standby should then use the same replication slot name as primary_slot_name . This ensures that the primary server does not remove any necessary WAL data in the time between the end of the base backup and the start of streaming replication on the new standby."},{"signature":{"text":"--sync-method= method","url":"/docs/18/app-pgbasebackup.html"},"summary":"When set to fsync , which is the default, pg_basebackup will recursively open and synchronize all files in the backup directory. When the plain format is used, the search for files will follow symbolic links for the WAL directory and each configured tablespace."},{"signature":{"text":"-v --verbose","url":"/docs/18/app-pgbasebackup.html"},"summary":"Enables verbose mode. Will output some extra steps during startup and shutdown, as well as show the exact file name that is currently being processed if progress reporting is also enabled."},{"signature":{"text":"--manifest-checksums= algorithm","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the checksum algorithm that should be applied to each file included in the backup manifest. Currently, the available algorithms are NONE , CRC32C , SHA224 , SHA256 , SHA384 , and SHA512 . The default is CRC32C ."},{"signature":{"text":"--manifest-force-encode","url":"/docs/18/app-pgbasebackup.html"},"summary":"Forces all filenames in the backup manifest to be hex-encoded. If this option is not specified, only non-UTF8 filenames are hex-encoded. This option is mostly intended to test that tools which read a backup manifest file properly handle this case."},{"signature":{"text":"--no-estimate-size","url":"/docs/18/app-pgbasebackup.html"},"summary":"Prevents the server from estimating the total amount of backup data that will be streamed, resulting in the backup_total column in the pg_stat_progress_basebackup view always being NULL ."},{"signature":{"text":"--no-manifest","url":"/docs/18/app-pgbasebackup.html"},"summary":"Disables generation of a backup manifest. If this option is not specified, the server will generate and send a backup manifest which can be verified using pg_verifybackup . The manifest is a list of every file present in the backup with the exception of any WAL files that may be included. It also stores the size, last modification time, and an optional checksum for each file."},{"signature":{"text":"--no-slot","url":"/docs/18/app-pgbasebackup.html"},"summary":"Prevents the creation of a temporary replication slot for the backup."},{"signature":{"text":"--no-verify-checksums","url":"/docs/18/app-pgbasebackup.html"},"summary":"Disables verification of checksums, if they are enabled on the server the base backup is taken from."},{"signature":{"text":"-d connstr --dbname= connstr","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies parameters used to connect to the server, as a connection string ; these will override any conflicting command line options."},{"signature":{"text":"-h host --host= host","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for a Unix domain socket. The default is taken from the PGHOST environment variable, if set, else a Unix domain socket connection is attempted."},{"signature":{"text":"-p port --port= port","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. Defaults to the PGPORT environment variable, if set, or a compiled-in default."},{"signature":{"text":"-s interval --status-interval= interval","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the number of seconds between status packets sent back to the source server. Smaller values allow more accurate monitoring of backup progress from the server. A value of zero disables periodic status updates completely, although an update will still be sent when requested by the server, to avoid timeout-based disconnects. The default value is 10 seconds."},{"signature":{"text":"-U username --username= username","url":"/docs/18/app-pgbasebackup.html"},"summary":"Specifies the user name to connect as."},{"signature":{"text":"-w --no-password","url":"/docs/18/app-pgbasebackup.html"},"summary":"Prevents issuing a password prompt. If the server requires password authentication and a password is not available by other means such as a .pgpass file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password."},{"signature":{"text":"-W --password","url":"/docs/18/app-pgbasebackup.html"},"summary":"Forces pg_basebackup to prompt for a password before connecting to the source server."},{"signature":{"text":"-V --version","url":"/docs/18/app-pgbasebackup.html"},"summary":"Prints the pg_basebackup version and exits."},{"signature":{"text":"-? --help","url":"/docs/18/app-pgbasebackup.html"},"summary":"Shows help about pg_basebackup command line arguments, and exits."}],"title":"Documented options"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
