Problems to backup my Production Database in Postgres


I’m facing issues trying to backup my production database. This is the step I’m following:

1: Open a Command-line window where you launched your app (e.g., c:\moon). Type:
fly proxy 15432:5433 -a moon-db

2: Open a new Command-line window of the same directory. Type:
pg_dump -p 15432 -h localhost -U postgres -c -d moon -f db_backup

It will prompt you for password. I’m using the password from my DATABASE_URL env variable that have this format: postgres://moon:XXXXXXXXXXXX@top2.nearest.of.moon-db.internal:5432/moon

I’m using the password as XXXXXXXXXXXX (I’m hiding it)

And then receive this error message in the terminal:

pg_dump: error: connection to database "moon" failed: FATAL: password authentication failed for user "postgres"

Can you help me to see what is wrong in the process? And if the password isn’t in the DATABASE_URL, where can I find it?

Can you retry this with -U moon instead postgres since the password you provided corresponds to that user?

I tried, now apper a new error related the version of pg_dump:
pg_dump: error: server version: 14.4 (Debian 14.4-1.pgdg110+1); pg_dump version: 12.11 (Ubuntu 12.11-0ubuntu0.20.04.1) pg_dump: error: aborting because of server version mismatch

Do you know how can I solve it?

Already solved. The problem was related to my local postgresql version. I updated it for my Ubuntu system with this commands:

  1. wget --quiet -O - | sudo apt-key add -

  2. sudo sh -c 'echo "deb $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

3. sudo apt-get update

4. sudo apt-get install postgresql-14

After it run the command again and worked.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.