1

I'm trying to backup all the content from my postgresql database. I have 2 sites my live one and the dev one. All the code is in sync i just want to copy all the data across to the dev site to do some tests on then add data and then copy it back across.

I've tried going through the documentation on the postgres site and i'm having now luck.

commands i ran to do the dump / restore:

pg_dump db_name > joshtestdump 
psql dbname < joshtestdump –

When i run the first command to dump the database, I get the following error message:

pg_dump: [archiver (db)] connection to database "db_name" failed: FATAL:  Ident authentication failed for user "josh"

Just to add, the username and password for the databse are blank. Does this have an affect on anything?

I'm new to postgreSQL and every tutorial on the web pretty much does the same thing.

Please let me know if you need anymore details!

Here are my DB details:

DATABASE_ENGINE = 'postgresql_psycopg2'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'db_name'             # Or path to database file if using sqlite3.
DATABASE_USER = ''             # Not used with sqlite3.
DATABASE_PASSWORD = ''         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.

Thanks,

Josh

UPDATED

1
  • I used a python-psycopg2 solution: generating sql that makes a copy of the db Commented Jul 18, 2012 at 15:27

1 Answer 1

5
  1. Why are you using gzip rather than --format to get a compressed dump?
  2. Why are you doing this as root?
  3. Why are you not using pg_restore to restore your database?
  4. Why are you favouring random web tutorials over the actual manuals

    pg_dump -U some_user -Fc database_name > mydb.dump

    pg_restore -U some_user -d database_name mydb.dump

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

4 Comments

Sorry I may not have mentioned here are the original commands i ran to do the dump / restore: pg_dump db_name > joshtestdump psql dbname < joshtestdump
I'm not logged in as the root I am logged in as my SSH user account. Do i need to be logged in as the DB?
@JoshDavies You are using sudo which means run the command as root (it stands for superuser do).
Ok thanks for that Simon! The only problem i have is when i run it without sudo i get this error message: pg_dump: [archiver (db)] connection to database "db_name" failed: FATAL: Ident authentication failed for user "josh"

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.