Primary Server
Setup Firewalls to allow connectivitysudo ufw allow from <standbyIP> to any port <port> proto <protocol:-tcp>
sudo ufw reload
Test from <standbyIP>
telnet <primaryserver> <port>
# Must established connection
Create replicator user with replication features.
CREATE ROLE replicator WITH REPLICATION LOGIN PASSWORD 'Passwrrd';
Modify main configuration file
wal_level=logical
Established which hosts are allowed to connect for replication
nano <postgres>/pg_hba.conf
# Set Client authentication method. SSL is preferred
hostssl replication replicator <standbyip>/32 md5
Standby Server
Create a backup into the $PGDATA directory for postgres
pg_basebackup-h $PRIMARY_HOST -U $PRIMARY_USER -D $STANDBYDIR -P-R-v-Xstream
-R: The option creates two files; an empty recovery configuration file called standby.signal and a primary node connection settings file called postgresql.auto.conf. The standby.signal file contains connection information about the primary node and the postgresql.auto.conf file informs your replica cluster that it should operate as a standby server.