Docker Community Forums

Share and learn in the Docker community.

Newbie with postgres

Hi everybody,

running docker on a Synology NAS with postgres 11.1 as database to odoo 13 (also in a docker).

Do not why, but odoo can not use the postgres database anymore. My idea now has been to create a dump out of the old database and import that to a new one.
Opened a terminal, connected to the nas and switched to the database via

docker exec -u 0 -it name-of-the-database bash
pg_dump name-of-the-database > sicherung_dump.sql
Result of it:
pg_dump: [archiver (db)] connection to database “name-of-the-database” failed: FATAL: role “root” does not exist

So I tried to login as the user of the database (to be sure I used env to see everything…)
env
LANG=en_US.utf8
HOSTNAME=XXXXXXX
PG_MAJOR=11
PWD=/
HOME=/root
PG_VERSION=11.1-3.pgdg90+1
GOSU_VERSION=1.11
PGDATA=/var/lib/postgresql/data
POSTGRES_DB=postgres
TERM=xterm
POSTGRES_PASSWORD=XXXpassword_to_odoo
POSTGRES_USER=XXXodoo
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/postgresql/11/bin
_=/usr/bin/env

Result of it:
Login incorrect

So what can I do to create a dump out of this database?

What had I done so far:
Tried to install pgAdmin with following commands

sudo docker run -d --restart=always
–volume=pgvolume:/pgdata
–env PGADMIN_DEFAULT_EMAIL=psb@XXX.YY
–env PGADMIN_DEFAULT_PASSWORD=secret
–link name-of-the-database
–name=“pgadmin4”
-p dpage/pgadmin4

Result of it: Not working…

Also installed pgAdmin on other PC in network, tried to connect via port 5432 and the IP of the NAS to the database - Result is: Unable to connect to server:
Could not connect to server: Connection refused
Is the server running on host “192.168.XXX.XXX” and accepting
TCP/IP connections on port 5432?

Connected then again via terminal:
psql -h localhost -p 5432 -U odoo -d postgres
Wow - working
But how can I now create a dump?

And please have a little mercy on me - I am a user and not an IT specialist.

kind regards
Peter

Seems to be a postgres, not a docker question. Add the user parameter -U odoo to pg_dump.
The file you create this way will be located inside the container. If you want it on your host you can mount the current folder into the container if you use the parameter -v "$(pwd):/data" when you start it, then send the output to /data/sicherung_dump.sql.