0

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.

  • 1
    Please remove those lines from 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. – dezso Sep 19 at 10:33
  • Thanks @dezso for the useful advice and pointing out my mistake from security point of view.db is running there. No connection between these 2 server..So, should I configure any SSH or anything else here? – Shiwangini Shishulkar Sep 19 at 10:36
1

What are the permissions set on the file pg_hba.conf?

Does the postgres user have the ability to read it?

Here is my configuration:

-rw-------. 1 postgres postgres  4334 Apr  4 22:14 ./pg_hba.conf
0

In order to fix these kind of errors, first I have got allowed connections from another servers and then I realized by mistake, I have updated pg_hba.conf file with "root" user login..Later on, I created the same file with "postgres" user and then the problem got fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.