PostgreSQL: Can the archive command for master and standby point to the same directory

postgresqlpostgresql-9.1replication

I use streaming replication and PITR (WAL files) in my cluster, currently I have different versions of postgresql.conf for the master and the standby server.

The only difference in the files is the archive command, that points to a different directory.

for example, on master I have:

archive_command = 'cp %p /dbckp/server1master/%f'

And on the standby:

archive_command = 'cp %p /dbckp/server2master/%f'

I figure that if the standby is not generating any archives while on 'standby mode' I could use the same directory and have a single postgresql.conf.

Best Answer

In theory this should work. After all, the files should be identical. In practice I think it is scary and I wouldn't do it. I would worry about file locking contention, and also the fact that if I am archiving twice to two locations I get a full backup of the WAL's esp, if I send to different file servers. If one goes belly up at a bad time, I can still get logs off the other for PITR.

Keep in mind that if something goes wrong with this setup, you can lose PITR ability to roll forward beyond a certain point. Additionally if you set things up how they are now, you may be able to use file permissions and attributes to prevent overwriting existing parts of existing files which can be very helpful in backup assurance.