User Tools

Site Tools


docu:csheet:sysadm:db:psql:dumping

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
docu:csheet:sysadm:db:psql:dumping [2020/02/21 16:10]
admin created
docu:csheet:sysadm:db:psql:dumping [2021/06/08 13:46] (current)
admin
Line 2: Line 2:
  
 \\ \\
-This is a little cheatsheet on Postgres SQL **dumping and restoring** commands+This is a little cheatsheet on Postgres SQL **dumping and restoring** commands\\ 
 + 
 +Dumping commands
 <code bash> <code bash>
 # dump without username # dump without username
Line 9: Line 11:
 # dump using a username and database # dump using a username and database
 pg_dump -Uusername -d DATABASE pg_dump -Uusername -d DATABASE
 +</code>
 +
 +Restoring comands
 +<code bash>
 +# 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
 </code> </code>
docu/csheet/sysadm/db/psql/dumping.1582301457.txt.gz · Last modified: 2020/02/21 16:10 by admin