0

I am on Ubuntu 18.04 and I am using Postgresql database. I ran the command

pg_dump dbname > db.bak

but when I do this, it outputs nothing. I tried to supply a path to the backup and the file does not show up.

My exact commands ran are:

sudo -i -u postgres
psql
pg_dump dbname > db.bak
pg_dump dbname > /db.bak
7
  • I am also running this from a venv if that makes any difference. Commented May 5, 2020 at 14:12
  • Oh, can you run the command from the command prompt, and not from within psql? Commented May 5, 2020 at 14:14
  • From within psql you can type \! pwd to see what the current directory is. Commented May 5, 2020 at 14:15
  • When running outside of psql I get "connection to database "mydb" failed; FATAL: role "john" does not exist. Commented May 5, 2020 at 14:19
  • the directory is /var/lib/postgresql. I have searched in and I don't see any backups Commented May 5, 2020 at 14:20

1 Answer 1

2

pg_dump -U myuser -h localhost mydb > db.sql

This worked for me.

Sign up to request clarification or add additional context in comments.

1 Comment

where is the back located ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.