I want to take backup of my PostgreSQL database cluster from another server. I'm using below command ,from another server:
[root@shiwangini2 pgsql]# sudo -u postgres pg_basebackup -h 192.168.XX.XX -p 5432 -Ft -D /var/lib/pgsql/db_file_backup
However, I'm getting below message after running this:
[root@shiwangini2 pgsql]# sudo -u postgres pg_basebackup -h
192.168.XX.XX -p 5432 -Ft -D /var/lib/pgsql/db_file_backup
Password:
pg_basebackup: could not get write-ahead log end position from server: ERROR: could not open file "./pg_hba.conf": Permission denied pg_basebackup: removing contents of data directory "/var/lib/pgsql/db_file_backup"
In order to fix this,after googling I updated my server's pg_hba.conf file like below,to allow connections from outside:
host all all 0.0.0.0/0
md5
host all all ::/0 md5
After that I restarted PotgreSQL services. And again, when I'm trying to backup it from another server, I'm still getting the same error. Please let me know if anything wrong I'm making here. Or any other way to take backup from another server.
pg_hba.conf
, unless you really want to allow the whole world to access your DB. Otherwise, the error message suggests there is no connection between the two machines (either no routing or a firewall rule disallowing it) - or the address is wrong, or the DB is really not running there.