Book Image

PostgreSQL Cookbook

By : Chitij Chauhan
Book Image

PostgreSQL Cookbook

By: Chitij Chauhan

Overview of this book

<p>PostgreSQL is an open source database management system. It is used for a wide variety of development practices such as software and web design, as well as for handling large datasets (big data).</p> <p>With the goal of teaching you the skills to master PostgreSQL, the book begins by giving you a glimpse of the unique features of PostgreSQL and how to utilize them to solve real-world problems. With the aid of practical examples, the book will then show you how to create and manage databases. You will learn how to secure PostgreSQL, perform administration and maintenance tasks, implement high availability features, and provide replication. The book will conclude by teaching you how to migrate information from other databases to PostgreSQL.</p>
Table of Contents (19 chapters)
PostgreSQL Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

A logical backup of a single PostgreSQL database


The pg_dump utility is used to back up a PostgreSQL database. It does make consistent backups even if the database is being used by other transactions. Dumps can be created in script or in archive file formats. Script dumps are usually plain text files that contain the SQL commands required to reconstruct the database to the state it was in at the time it was saved. Script dumps can also be used to reconstruct the database on other machines and architectures.

Getting ready

Please note that the dump keyword is evenly used here as a synonym for backup.

The pg_dump utility is considered to be a logical backup because it makes a copy of the data in the database by dumping out the contents of each table.

The basic syntax to take a logical backup of a single database is mentioned here:

pg_dump -U username -W -F t database_name > [Backup Location Path]

The usage of the options used with the pg_dump command is explained here:

  • U switch: The -U switch...