Postgresql – Access denied error when archiving WAL during postgresql 9.5 replication setup

postgresqlpostgresql-9.5replicationwindows

I want to setup Postgres replication on Windows. I followed the given youtube url step by step: youtube video.

For archive_command I use this:

archive_command = 'copy "%p" "\\\\ip-address of sharable drive\\soft\\\wal\\%f"' 

but when I look into the folder, folder is empty and WAL files are not transferred from pg_xlog to the desired location; it gives error access denied. In services.msc postgresql log on as network services.

services.msc

error log:

2018-04-30 16:34:06 IST LOG:  archive command failed with exit code 1
2018-04-30 16:34:06 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:34:07 IST LOG:  archive command failed with exit code 1
2018-04-30 16:34:07 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive1\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:34:08 IST LOG:  archive command failed with exit code 1
2018-04-30 16:34:08 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:34:08 IST WARNING:  archiving transaction log file "000000010000000E00000083" failed too many times, will try again later
2018-04-30 16:35:08 IST LOG:  archive command failed with exit code 1
2018-04-30 16:35:08 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:35:09 IST LOG:  archive command failed with exit code 1
2018-04-30 16:35:09 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:35:10 IST LOG:  archive command failed with exit code 1
2018-04-30 16:35:10 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:35:10 IST WARNING:  archiving transaction log file "000000010000000E00000083" failed too many times, will try again later
2018-04-30 16:36:10 IST LOG:  archive command failed with exit code 1
2018-04-30 16:36:10 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:36:11 IST LOG:  archive command failed with exit code 1
2018-04-30 16:36:11 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:36:12 IST LOG:  archive command failed with exit code 1
2018-04-30 16:36:12 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:36:12 IST WARNING:  archiving transaction log file "000000010000000E00000083" failed too many times, will try again later
2018-04-30 16:37:12 IST LOG:  archive command failed with exit code 1
2018-04-30 16:37:12 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:37:13 IST LOG:  archive command failed with exit code 1
2018-04-30 16:37:13 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:37:15 IST LOG:  archive command failed with exit code 1
2018-04-30 16:37:15 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:37:15 IST WARNING:  archiving transaction log file "000000010000000E00000083" failed too many times, will try again later 
2018-04-30 16:38:15 IST LOG:  archive command failed with exit code 1
2018-04-30 16:38:15 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:38:16 IST LOG:  archive command failed with exit code 1
2018-04-30 16:38:16 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:38:17 IST LOG:  archive command failed with exit code 1
2018-04-30 16:38:17 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:38:17 IST WARNING:  archiving transaction log file "000000010000000E00000083" failed too many times, will try again later
2018-04-30 16:39:17 IST LOG:  archive command failed with exit code 1
2018-04-30 16:39:17 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:39:18 IST LOG:  archive command failed with exit code 1
2018-04-30 16:39:18 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:39:19 IST LOG:  archive command failed with exit code 1
2018-04-30 16:39:19 IST DETAIL:  The failed archive command was: copy %\ip-address of sharable drive\soft\SUJITwal\000000010000000E00000083
2018-04-30 16:39:19 IST WARNING:  archiving transaction log file "000000010000000E00000083" failed too many times, will try again later

Best Answer

You just need to correct archive_command just replace IP-address of path to which wal files will be archived e.g archive_command = 'copy "%p" "\\10.10.0.123\\soft\\\wal\\%f"'

Also make sure the path permission is set to postgres user if not

chown postgres:postgres \\10.10.0.123\\soft\\\wal\\%f"' 

If still unable to get archive files check the connection to IP may be having connection issue