Postgresql – How to make pg_basebackup use temporary replication slots

backuppg-basebackuppostgresqlpostgresql-10write-ahead-logging

This article
https://blog.hagander.net/another-couple-of-steps-on-my-backup-crusade-235/
states
that temporary replication slots can be "used to prevent the wal on the server from being removed while a downstream replica or backup still needs it"

Apparently, temporary replication slots can now be used by pg_basebackup since 10.
My question is how do we enable this feature or does it happen now automatically with pg_basebackup?

Also, is this feature related to the -X stream option
"Stream the write-ahead log while the backup is created. This will open a second connection to the server and start streaming the write-ahead log in parallel while running the backup. Therefore, it will use up two connections configured by the max_wal_senders parameter. As long as the client can keep up with write-ahead log received, using this mode requires no extra write-ahead logs to be saved on the master." which is enabled by default?
https://www.postgresql.org/docs/current/static/app-pgbasebackup.html

Best Answer

The slot to use for -X stream is specified with the --slot option. Its documentation says:

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.