diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml index 1640c67fd67..611e94911a4 100644 --- a/doc/src/sgml/backup.sgml +++ b/doc/src/sgml/backup.sgml @@ -530,7 +530,8 @@ tar -cf backup.tar /usr/local/pgsql/data character in the command. The simplest useful command is something like -archive_command = 'cp -i %p /mnt/server/archivedir/%f </dev/null' +archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' # Unix +archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"' # Windows which will copy archivable WAL segments to the directory /mnt/server/archivedir. (This is an example, not a @@ -562,17 +563,19 @@ archive_command = 'cp -i %p /mnt/server/archivedir/%f </dev/null' preserve the integrity of your archive in case of administrator error (such as sending the output of two different servers to the same archive directory). + + + It is advisable to test your proposed archive command to ensure that it indeed does not overwrite an existing file, and that it returns - nonzero status in this case. We have found that cp -i does - this correctly on some platforms but not others. If the chosen command - does not itself handle this case correctly, you should add a command - to test for pre-existence of the archive file. For example, something - like - -archive_command = 'test ! -f .../%f && cp %p .../%f' - - works correctly on most Unix variants. + nonzero status in this case. + The example command above for Unix ensures this by including a separate + test step. On some Unix platforms, cp has + switches such as