02 January 2008

Import / Export a postgres db

postgres is the database user. On ubuntu, you should run this command as the user "postgres": su postgres (password by default is 'password' !)

Dump a database into a sql script:

pg_dump database_name -Upostgres -W > ~/dump_script.sql

Restore the database from sql script:

psql -U postgres database_name -f - < dump_script.sql

No comments: