how to set permission, so I can run pg_dumd in a cron job

From: robert rottermann <robert(at)redcor(dot)ch>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: how to set permission, so I can run pg_dumd in a cron job
Date: 2021-03-13 16:16:17
Message-ID: 08762210-ad92-7b0d-a1bc-45301bd76582@redcor.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Friends

I would like to have a cronjob creating a dump of a db.

I am on a ubuntu 18 lts, potgres v10.

I have a user robert with superuser db permission.

a database "mydb" of which I would like to to a nightly dump.

I tried to set thing in hba_conf like this:

# Database administrative login by Unix domain socket
local   all             postgres peer

# TYPE  DATABASE        USER            ADDRESS METHOD

# "local" is for Unix domain socket connections only
local   all             all trust
# IPv4 local connections:
host    all             all             127.0.0.1/32 trust

and I create a /root/.pgpass file with this content

hostname:port:database:username:password
localhost:5432:mydb:robert:

but still I get:

root(at)elfero:~# pg_dump  -U robert -d mydb > dumps/mydb.sql
pg_dump: [archiver (db)] connection to database "mydb" failed: FATAL:  Peer
authentication failed for user "robert"

can you please give me a hand

thanks

robert

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2021-03-13 16:17:00 Re: How to recover data from 9.3 data directory
Previous Message Andrus 2021-03-13 15:25:10 Re: How to recover data from 9.3 data directory