repmgr standby clone clones a PostgreSQL node from another PostgreSQL node, typically the primary, but optionally from any other node in the cluster or from Barman. It creates the recovery.conf file required to attach the cloned node to the primary node (or another standby, if cascading replication is in use).
Note: repmgr standby clone does not start the standby, and after cloning repmgr standby register must be executed to notify repmgr of its presence.
Note that by default, all configuration files in the source node's data directory will be copied to the cloned node. Typically these will be postgresql.conf, postgresql.auto.conf, pg_hba.conf and pg_ident.conf. These may require modification before the standby is started.
In some cases (e.g. on Debian or Ubuntu Linux installations), PostgreSQL's configuration files are located outside of the data directory and will not be copied by default. repmgr can copy these files, either to the same location on the standby server (provided appropriate directory and file permissions are available), or into the standby's data directory. This requires passwordless SSH access to the primary server. Add the option --copy-external-config-files to the repmgr standby clone command; by default files will be copied to the same path as on the upstream server. Note that the user executing repmgr must have write access to those directories.
To have the configuration files placed in the standby's data directory, specify --copy-external-config-files=pgdata, but note that any include directives in the copied files may need to be updated.
Tip: For reliable configuration file management we recommend using a configuration management tool such as Ansible, Chef, Puppet or Salt.
When initially cloning a standby, you will need to ensure that all required WAL files remain available while the cloning is taking place. To ensure this happens when using the default pg_basebackup method, repmgr will set pg_basebackup's --xlog-method parameter to stream, which will ensure all WAL files generated during the cloning process are streamed in parallel with the main backup. Note that this requires two replication connections to be available (repmgr will verify sufficient connections are available before attempting to clone, and this can be checked before performing the clone using the --dry-run option).
To override this behaviour, in repmgr.conf set pg_basebackup's --xlog-method parameter to fetch:
and ensure that wal_keep_segments is set to an appropriately high value. See the pg_basebackup documentation for details.
Note: From PostgreSQL 10, pg_basebackup's --xlog-method parameter has been renamed to --wal-method.