Forrest logo
back to the pg_dump tool

pg_dump:tldr:e06f3

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

This command is a PostgreSQL database utility command called "pg_dump" that is used to create a backup of a PostgreSQL database. Here's a breakdown of the command:

  • pg_dump is the actual command that performs the backup operation.
  • -a is an option used with pg_dump to specify that only table data should be backed up, excluding the database schema and settings.
  • ${db_name} is a placeholder that should be replaced with the actual name of the database you want to backup. For example, if your database is named "mydatabase", you would replace ${db_name} with mydatabase.
  • > is the output redirection operator. It redirects the output of the pg_dump command to a file instead of displaying it on the console.
  • ${path-to-output_file-sql} is a placeholder that should be replaced with the actual path and filename where you want to save the backup file. For example, if you want to save the backup file as "/home/user/backup.sql", you would replace ${path-to-output_file-sql} with /home/user/backup.sql.

Overall, this command will create a backup file containing the table data of the specified PostgreSQL database and save it at the specified location.

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