Postgresql – How archive command works in postgres

postgresqlreplication

Just wondering how does this postgres wal archive command works in replication:

rsync -z -a --contimeout=120 --partial-dir=.rsync-partial %p db-slave.sr1.net::primary-wal-archive-share/%f

what does this %p and %f mean here?

Best Answer

from docs:

The local shell command to execute to archive a completed WAL file segment. Any %p in the string is replaced by the path name of the file to archive, and any %f is replaced by only the file name. (The path name is relative to the working directory of the server, i.e., the cluster's data directory.) Use %% to embed an actual % character in the command. It is important for the command to return a zero exit status only if it succeeds

(emphasis mine)

Also take a look at setting WAL archiving