How to Back Up a PostgreSQL Database Using pg_dump
PostgreSQL includes a utility called "pg_dump" that can be used to dump database information into a file for backup purposes.
The pg_dump utility is run from the Linux command line. The basic syntax of the command is:
pg_dump name_of_database > name_of_backup_file
The command must be run by a user with privileges to read all of the database information, so it is run as the superuser most of the time.
For a real-world example, we can log into the "postgres" user and execute the command on the default database, also called "postgres":
sudo su - postgres pg_dump postgres > postgres_db.bak
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 10/27/14, 2:29 AM|
|Seen: 1008 times|
|Last updated: 3/16/15, 8:10 AM|