I am using Postgres 9.2.1 and am saving my archivable WAL over a NFS share.

I just use the basic command, given as an example in the postgresql.conf

test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f

Does the cp command somehow secure that my backup server, which reads the WAL archives, doesn't read half copied WAL files? Do I have to manually define a cp command that lets the file end with .tmp and then call rename afterwards to give it its proper name?

Has someone got a example of an save archive_command?

1 Answer 1


Neither NFS nor cp will protect you from partial write. The usual way of mitigating problems with write atomicity is to use a temporary file and a mv after copying (or writing) is complete. You might use something like:

    test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/tmp/%f && \
    mv /mnt/server/archivedir/tmp/%f /mnt/server/archivedir/%f

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.