pg_dumpall
The command line tool "pg_dumpall" is used in PostgreSQL database management systems. It allows you to create a complete and consistent backup of all databases in a PostgreSQL cluster. By default, it creates a plain-text script that can be used to re-create the database objects and data. This tool can be helpful for migrating databases between servers or for disaster recovery purposes. It captures database objects such as tables, views, indexes, functions, triggers, and schemas. The backup is created in a format compatible with PostgreSQL's SQL dialect. It supports various options to specify the output file, compression, and inclusion/exclusion of certain objects. Using the "--clean" option in pg_dumpall ensures that the backup includes SQL commands to drop and recreate the objects, ensuring a clean restore. Users can authenticate using their respective passwords or specify the "--no-passwords" option to exclude password authentication. Pg_dumpall is typically run as a superuser since it requires extensive access to database objects and system catalogs.
List of commands for pg_dumpall:
-
pg_dumpall:tldr:b4bb9 pg_dumpall: Dump all databases using a specific username.$ pg_dumpall --username=${username} > ${filename-sql}try on your machineexplain this command
-
pg_dumpall:tldr:dc6c0 pg_dumpall: Same as above, customize host and port.$ pg_dumpall -h ${host} -p ${port} > ${output_file-sql}try on your machineexplain this command
-
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 machineexplain this command
-
pg_dumpall:tldr:f86ba pg_dumpall: Dump only database data into an SQL-script file.$ pg_dumpall --data-only > ${filename-sql}try on your machineexplain this command
-
pg_dumpall:tldr:faa60 pg_dumpall: Dump all databases.$ pg_dumpall > ${filename-sql}try on your machineexplain this command
-
pg_dumpall:tldr:fff02 pg_dumpall: Dump all databases into a custom-format archive file with moderate compression.$ pg_dumpall -Fc > ${output_file-dump}try on your machineexplain this command