2

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?

1 Answer 1

1

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

6
  • What if the data directory contain multiple wal files? postgres will assign latest wal as %f? Commented Jan 19, 2017 at 15:08
  • Also, if i want to ship this wal file to a different server on a different network after the first rsync, will %f stay same through out all rsync runs? Commented Jan 19, 2017 at 15:09
  • one shared folder. master writes to it (archive_command), slaves read from it (restore_command in recovery.conf)
    – Vao Tsun
    Commented Jan 19, 2017 at 15:22
  • Will the following archive command work or is it recommended? rsync -z -a --contimeout=120 %p db-slave.sr1.net::primary-wal-archive-share/%f && upload.sh %p Given last upload.sh script uploads my data dir to another server and creates new data/pg_xlog dir Commented Jan 19, 2017 at 15:37
  • Dino: is you intent to send the WAL archives to more than one place, i.e. an archive server and a hot standby server? Commented Jan 20, 2017 at 3:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.