Forrest logo
back to the pg_restore tool

pg_restore:tldr:7a534

pg_restore: Clean database objects before creating them.
$ pg_restore --clean -d ${db_name} ${archive_file-dump}
try on your machine

The command pg_restore is used to restore a PostgreSQL database from backup files created by pg_dump. Let's break down the command and explain each part:

  • pg_restore: This is the command itself, used for restoring a database.
  • --clean: This flag tells pg_restore to drop the existing database objects before restoring. It ensures a clean state before restoring the backup.
  • -d ${db_name}: This specifies the name of the database where the backup will be restored. Replace ${db_name} with the actual name of your target database.
  • ${archive_file-dump}: This is the path to the backup file that will be used for restoration. Replace ${archive_file-dump} with the actual path to your backup file.

In summary, this command will restore the specified PostgreSQL backup file into a specified database, and before restoring, it will drop any existing database objects to create a clean state.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the pg_restore tool