Forrest logo
tool overview
On this page you find all important commands for the CLI tool pg_restore. If the command you are looking for is missing please ask our AI.

pg_restore

  1. pg_restore is a command line tool used in PostgreSQL database management systems.
  2. It is used to restore a database from a backup created by the pg_dump command or any other compatible tool.
  3. pg_restore allows the user to rebuild the database objects and data from a backup file.
  4. This tool is mainly used for disaster recovery or migrating a database to a new server.
  5. It can handle both plain text and binary formatted backups created by pg_dump.
  6. When restoring, pg_restore applies the correct sequence of commands to recreate tables, indexes, and other database objects.
  7. It also restores the data into these objects based on the backup file.
  8. pg_restore provides options to specify a target database, tablespaces, or even the schema to restore into.
  9. The user can choose to restore the entire database or only specific parts such as tables or functions.
  10. Overall, pg_restore simplifies the process of database restoration, ensuring data integrity and structure are preserved.

List of commands for pg_restore:

  • pg_restore:tldr:1bd61 pg_restore: List database objects included in the archive.
    $ pg_restore --list ${archive_file-dump}
    try on your machine
    explain this command
  • pg_restore:tldr:4c478 pg_restore: Same as above, customize host and port.
    $ pg_restore -h ${host} -p ${port} -d ${db_name} ${archive_file-dump}
    try on your machine
    explain this command
  • pg_restore:tldr:59581 pg_restore: Restore an archive into an existing database.
    $ pg_restore -d ${db_name} ${archive_file-dump}
    try on your machine
    explain this command
  • pg_restore:tldr:6f1e3 pg_restore: Same as above, customize username.
    $ pg_restore -U ${username} -d ${db_name} ${archive_file-dump}
    try on your machine
    explain this command
  • 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
    explain this command
  • pg_restore:tldr:82157 pg_restore: Use multiple jobs to do the restoring.
    $ pg_restore -j ${2} -d ${db_name} ${archive_file-dump}
    try on your machine
    explain this command
tool overview