I am trying to modify postgresql.conf (Postgre SQL 10.0 in Ubuntu 18.04 VPS) to configure the advance write log (WAL).
AIUI, the commands should be:
wal_level = replica # minimal, replica, or logical archive_mode = on # enables archiving; off, on, or always # (change requires restart) archive_command = 'cp %p /var/lib/postgresql/10/main/pg_wal/%f' archive_timeout = 600 # force a logfile segment switch after this # number of seconds; 0 disables
AIUI,% p refers to the database file (to be archived) and% f refers to the file name that will contain the copy of that database file.
In this case: I am telling you to copy the database file every 5 minutes to the / pg_wal directory.
However, this is clearly not correct as the error log files show:
cp: 'pg_wal/000000010000000000000002' and '/var/lib/postgresql/10/main/pg_wal/000000010000000000000002' are the same file 2020-02-16 21:01:05.857 UTC (20707) LOG: archive command failed with exit code 1 2020-02-16 21:01:05.857 UTC (20707) DETAIL: The failed archive command was: cp pg_wal/000000010000000000000002 /var/lib/postgresql/10/main/pg_wal/000000010000000000000002
Therefore, I am not sure how% p and / or% f should be used. If someone could present the syntax, I would be very grateful.