Drop objects before recreating them during restore.

Section: pg_dump and pg_restore Basics

Restore with clean

bash
bash
pg_restore -h localhost -U postgres -d appdb --clean --if-exists appdb.dump
Explanation

See summary for usage details.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing pg_dump and pg_restore Basics
Restore archive to database
Restore a custom or directory archive into a database.
OpenIn sheetbashsame section
Restore plain SQL dump
Replay a plain-text SQL dump with psql.
OpenIn sheetbashsame section
Custom format dump
Create a compressed custom-format backup archive.
OpenIn sheetbashsame section
Directory format dump
Create a directory-format dump that supports parallel restore.
OpenIn sheetbashsame section
Plain SQL dump
Create a plain-text SQL dump.
OpenIn sheetbashsame section
Schema-only dump
Export only DDL without row data.
OpenIn sheetbashsame section