User Tools

Site Tools


docu:csheet:sysadm:db:psql:dumping

Dumping and restoring Postgres databases


This is a little cheatsheet on Postgres SQL dumping and restoring commands

Dumping commands

# dump without username
pg_dump DATABASE
 
# dump using a username and database
pg_dump -Uusername -d DATABASE

Restoring comands

# create user if needed (with password)
createuser -P username
 
# drop and create the database
dropdb DATABASE
createdb DATABASE
 
# restore it from .sql dump file
psql --set ON_ERROR_STOP=on DATABASE < INFILE.sql
docu/csheet/sysadm/db/psql/dumping.txt · Last modified: 2021/06/08 13:46 by admin