Thread: archive_commnad parameter question
Hello,
I am new in PostgreSQL and I am trying to understand what the “test” word is representing in the archive_command configuration that the PostgreSQL documentation is showing as the format on how to set up this parameter
archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' # Unix
Does anybody know what is “test” representing in this parameter configuration?
Thank in advance for your help on this.
Regards,
Allie
On 4/19/21 2:09 PM, Allie Crawford wrote: > Hello, > > I am new in PostgreSQL and I am trying to understand what the “test” > word is representing in the archive_command configuration that the > PostgreSQL documentation is showing as the format on how to set up this > parameter > > archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p > /mnt/server/archivedir/%f' # Unix > > Does anybody know what is “test” representing in this parameter > configuration? Per the docs: "This is an example, not a recommendation, and might not work on all platforms." test in this case refers to a shell command: https://www.computerhope.com/unix/bash/test.htm So this only works in environments that have that command. > > Thank in advance for your help on this. > > Regards, > > Allie > -- Adrian Klaver adrian.klaver@aklaver.com
On 20 Apr 2021, at 7:09, Allie Crawford wrote: > archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p > /mnt/server/archivedir/%f' # Unix > > Does anybody know what is “test” representing in this parameter > configuration? > my_unix_prompt> man test gives: Tests the expression given and sets the exit status to 0 if true, and 1 if false. An expression is made up of one or more operators and their arguments. In other words “test” here is a unix command which evaluated the expression supplied via the arguments. Mostly used in its alternate form of “[ … ]” in shell scripts Gavan Schneider —— Gavan Schneider, Sodwalls, NSW, Australia Explanations exist; they have existed for all time; there is always a well-known solution to every human problem — neat, plausible, and wrong. — H. L. Mencken, 1920
On 2021-04-19 21:09:13 +0000, Allie Crawford wrote: > I am new in PostgreSQL and I am trying to understand what the “test” word is > representing in the archive_command configuration that the PostgreSQL > documentation is showing as the format on how to set up this parameter > > archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/ > archivedir/%f' # Unix > > Does anybody know what is “test” representing in this parameter configuration? "test" is a unix command for testing stuff (as the name implies). "test -f" in particular tests whether the argument exists and is a regular file) and the "!" inverts the result. So the whole line checks that the target *doesn't* already exist before attempting to copy over it. hp -- _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!"
Attachment
Hello,
I am new in PostgreSQL and I am trying to understand what the “test” word is representing in the archive_command configuration that the PostgreSQL documentation is showing as the format on how to set up this parameter
archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' # Unix
Does anybody know what is “test” representing in this parameter configuration?
Hi All,
I have implemented Stream replication in one of my environments, and for some reason even though all the health checks are showing that the replication is working, when I run manual tests to see if changes are being replicated, the changes are not replicated to the standby postgresql environment. I have been researching for two day and I cannot find any documentation that talks about the case I am running into. I will appreciate if anybody could take a look at the details I have detailed below and give me some guidance on where the problem might be that is preventing my changes for being replicated. Even though I was able to instantiate the standby while firewalld was enabled, I decided to disable it just in case that it was causing any issue to the manual changes, but disabling firewalld has not had any effect, I am still not able to get the manual changes test to be replicated to the standby site. As you will see in the details below, the streaming is working, both sites are in sync to the latest WAL but for some reasons the latest changes are not on the standby site. How is it possible that the standby site is completely in sync but yet does not contain the latest changes?
Thanks in advance for any help you can give me with this problem.
Regards,
Allie
Details:
Master postgresql Environment
postgresql=# select * from pg_stat_replication;
-[ RECORD 1 ]----+------------------------------
pid | 1979089
usesysid | 16404
usename | replacct
application_name | walreceiver
client_addr | <standby server IP>
client_hostname | <standby server name>
client_port | 55096
backend_start | 2022-01-06 17:29:51.542784-07
backend_xmin |
state | streaming
sent_lsn | 0/35000788
write_lsn | 0/35000788
flush_lsn | 0/35000788
replay_lsn | 0/31000500
write_lag | 00:00:00.001611
flush_lag | 00:00:00.001693
replay_lag | 20:38:47.00904
sync_priority | 1
sync_state | sync
reply_time | 2022-01-07 14:11:58.996277-07
postgresql=#
postgresql=# select * from pg_roles;
rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolconnlimit | rolpassword | rolvaliduntil | rolbypassrls | rolconfig | oid
---------------------------+----------+------------+---------------+-------------+-------------+----------------+--------------+-------------+---------------+--------------+-----------+-------
postgresql | t | t | t | t | t | t | -1 | ******** | | t | | 10
pg_monitor | f | t | f | f | f | f | -1 | ******** | | f | | 3373
pg_read_all_settings | f | t | f | f | f | f | -1 | ******** | | f | | 3374
pg_read_all_stats | f | t | f | f | f | f | -1 | ******** | | f | | 3375
pg_stat_scan_tables | f | t | f | f | f | f | -1 | ******** | | f | | 3377
pg_read_server_files | f | t | f | f | f | f | -1 | ******** | | f | | 4569
pg_write_server_files | f | t | f | f | f | f | -1 | ******** | | f | | 4570
pg_execute_server_program | f | t | f | f | f | f | -1 | ******** | | f | | 4571
pg_signal_backend | f | t | f | f | f | f | -1 | ******** | | f | | 4200
replacct | t | t | t | t | t | t | -1 | ******** | | t | | 16404
(10 rows)
postgresql=#
postgresql=# create database test_replication_3;
CREATE DATABASE
postgresql=#
postgresql=# select datname from pg_database;
datname
--------------------
postgres
postgresql
template1
template0
stream
test_replication
test_replication_2
test_replication_3
(8 rows)
postgresql=#
postgresql=# SELECT pg_current_wal_lsn();
pg_current_wal_lsn
--------------------
0/35000788
(1 row)
postgresql=#
Standby postgresql Environment
postgresql=# select * from pg_stat_wal_receiver;
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
pid | 17340
status | streaming
receive_start_lsn | 0/30000000
receive_start_tli | 1
written_lsn | 0/35000788
flushed_lsn | 0/35000788
received_tli | 1
last_msg_send_time | 2022-01-07 14:09:48.766823-07
last_msg_receipt_time | 2022-01-07 14:09:48.767581-07
latest_end_lsn | 0/35000788
latest_end_time | 2022-01-07 14:08:48.663693-07
slot_name | wal_req_x_replica
sender_host | <Master Server IP>
sender_port | <Master server postgresql port#>
conninfo | user=replacct password=******** channel_binding=prefer dbname=replication host=<Master server IP> port=<postgresql port#> fallback_application_name=walreceiver sslmode=prefer sslcompression=0 ssl_min_protocol_version=TLSv1.2 gssencmode=prefer krbsrvname=postgres target_session_attrs=any
postgresql=#
postgresql=# select datname from pg_database;
datname
------------
postgres
postgresql
template1
template0
stream
(5 rows)
postgresql=# select pg_last_wal_receive_lsn();
pg_last_wal_receive_lsn
-------------------------
0/35000788
(1 row)
postgresql=#