Forrest logo
back to the pg_dump tool

pg_dump:tldr:cd40f

pg_dump: Dump database into an SQL-script file.
$ pg_dump ${db_name} > ${output_file-sql}
try on your machine

This command is used to create a backup or dump of a PostgreSQL database. Here's a breakdown of the command:

  • pg_dump: This is the command-line utility in PostgreSQL used for creating backups. It allows you to export the database in a format that can be easily imported later.

  • ${db_name}: This is a placeholder for the name of the database you want to backup. Replace it with the actual name of the database you want to dump.

  • >: This is the redirection symbol in the command-line interface. It tells the shell to redirect the output of the command to a file instead of displaying it on the console.

  • ${output_file.sql}: This is another placeholder for the name of the output file where the SQL dump will be stored. Replace it with the name you want to give to the output file. The .sql extension is commonly used to indicate that the file contains SQL statements.

So, by running this command and replacing the placeholders with the appropriate values, the database specified by ${db_name} will be dumped to a file with the name ${output_file.sql}.

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_dump tool