(TIL) PSQL: Restore a database

less than 1 minute read

To restore the dump, create a fresh database and then use pg_restore:

createdb my_new_database
pg_restore -d my_new_database my_database.dump

Note: the dumped tables will depend on some user role. You will need to ensure that this role exists on the database cluster where the restore is happening. You can use the createuser command if necessary.

See the pg_restore docs for more details.

Via jbranchaud/til.