PostgreSQL 12 – pg_basebackup Not Copying Config Files

postgresql

I am setting a master-slave architecture and have done the following steps thus far:

on master:

CREATE USER replicator WITH REPLICATION ENCRYPTED PASSWORD 'replicator';
theowl@postgresql:/etc/postgresql/12/main$ sudo vi pg_hba.conf
host    replication     replicator      192.168.56.8/24         md5

sudo systemctl restart  postgresql

on standby:

theowl@postgresql:/etc/postgresql/12/main$ sudo systemctl stop postgresql
postgres@postgresql:/etc/postgresql/12/main$ ls -ltr
total 0
pg_basebackup -h 192.168.56.7 -U replicator -p 5432 -D /etc/postgresql/12/main/ -Fp -Xs -P -R
postgres@postgresql:/etc/postgresql/12/main$ pg_basebackup -h 192.168.56.7 -U replicator -p 5432 -D /etc/postgresql/12/main/ -Fp -Xs -P -R
Password:
48423/48423 kB (100%), 1/1 tablespace
postgres@postgresql:/etc/postgresql/12/main$ ls -ltr
total 80
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_xact
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_twophase
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_stat
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_snapshots
drwx------ 4 postgres postgres 4096 Mar 12 16:35 pg_multixact
-rw------- 1 postgres postgres  224 Mar 12 16:35 backup_label
drwx------ 3 postgres postgres 4096 Mar 12 16:35 pg_wal
drwx------ 8 postgres postgres 4096 Mar 12 16:35 base
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_subtrans
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_replslot
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_notify
-rw------- 1 postgres postgres    3 Mar 12 16:35 PG_VERSION
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_tblspc
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_serial
drwx------ 4 postgres postgres 4096 Mar 12 16:35 pg_logical
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_dynshmem
drwx------ 2 postgres postgres 4096 Mar 12 16:35 pg_commit_ts
drwx------ 2 postgres postgres 4096 Mar 12 16:35 global
-rw------- 1 postgres postgres    0 Mar 12 16:35 standby.signal  
-rw------- 1 postgres postgres  268 Mar 12 16:35 postgresql.auto.conf

postgres@postgresql:/etc/postgresql/12/main$ cat postgresql.auto.conf
primary_conninfo = 'user=replicator password=replicator host=192.168.56.7 port=5432 sslmode=prefer sslcompression=0 gssencmode=prefer krbsrvname=postgres target_session_attrs=any'


postgres@postgresql:/etc/postgresql/12/main$ source ~/.pgsql_profile
postgres@postgresql:/etc/postgresql/12/main$ pg_ctl -D /etc/postgresql/12/main/ start
***waiting for server to start....postgres: could not access the server configuration file "/etc/postgresql/12/main/postgresql.conf": No such file or directory
 stopped waiting
pg_ctl: could not start server
Examine the log output.***

postgres@postgresql:/etc/postgresql/12/main$ cat ~/.pgsql_profile
export PATH=/usr/lib/postgresql/12/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin PAGER=less

Best Answer

If data_directory in the master's postgresql.conf is set to some non-default value, then the conf files will not be in the "real" data directory and will not be copied by pg_basebackup.

If the person in charge of the master is not you, you should ask them for a copy by some other means. Or you can just create your own.