Trouble retoring a postgresql database


I am new to posgresql.

I have just backed up my database, whose name is mydbname, using this command as indicated in pythonanywhere backup help:

$ pg_dump --host=myhost --port=myport --username=super --format=c --file=myfile.dump mydbname

The dump seems to be successful and I verified the .dump file.

But as the restore is not documented in pythonanywhere site, I was looking fir the right command and options and I tried this:

pg_restore --host=myhost --port=myport --username=super --create --exit-on-error --verbose myfile.dump

But it does not seem to create mydbname.

I then created the database manually (create database mydbname....)

Retried the same command, it was succussful, but it does not contain any relations????

Could you help me with the right options of pg_restore? I would like to restore structure and data!

Best regards!

Was the first time you ran it unsuccessful before creating the database? What error did it show?

And what did you do to check it it contains any data?

Before recreating the database, I had a message telling "The database mudbname does not exist"

I then went to postgresql console and typed the command \l My database did not appear.

Now, for restoring the database, I have to first drop it, then recreate it, regrant the privileges to my user... then execute the command:

pg_restore --host=myhost --port=myport--username=super -d mydbname myfile.dump

This restoring was successfull but I would like to avoid doing the drop and creation manually before calling the pg_restore.

As this is a general Postgres question, perhaps you'll be able to get the best help on the DBA Stack Exchange site?