Forrest logo
back to the pg_dumpall tool

pg_dumpall:tldr:ef370

pg_dumpall: Dump only schema (data definitions) into an SQL-script file.
$ pg_dumpall -s > ${output_file-sql}
try on your machine

The command "pg_dumpall -s > ${output_file-sql}" is used to create a backup of all the database schemas in PostgreSQL and save it to a file.

Here is a breakdown of the command:

  • "pg_dumpall" is the command-line utility provided by PostgreSQL to create backups of all databases.
  • "-s" is an option that tells pg_dumpall to only include the database schemas in the backup, excluding the data. This is useful when you want to create a schema-only backup.
  • ">" is a redirect operator used to redirect the output of the command to a file.
  • "${output_file-sql}" is a variable that represents the name of the output file where the backup will be saved. The "-sql" extension is appended to the value of the variable to indicate that the backup file is in SQL format.

To use this command, you need to replace "${output_file-sql}" with the actual name and path of the file where you want to save the backup. For example, if you want to save the backup in a file named "backup.sql" in the current directory, you can run the command as:

pg_dumpall -s > backup.sql

Make sure you have the necessary permissions to execute the command and write to the specified file 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_dumpall tool