Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PostgreSQL Administration Essentials

You're reading from   PostgreSQL Administration Essentials Discover efficient ways to administer, monitor, replicate, and handle your PostgreSQL databases

Arrow left icon
Product type Paperback
Published in Oct 2014
Publisher Packt
ISBN-13 9781783988983
Length 142 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Performing backups

Now that you have seen how to import and export data in the PostgreSQL world, it is time to focus your attention on performing basic backups. The backbone of a classical, text-based backup is a program called pg_dump.

Handling pg_dump

The pg_dump is a command-line tool, easy to use, and is capable of extracting a database in a plain text format. Here is how the most simplistic backup of them all works:

$ pg_dump test > /tmp/dump.sql

The dump.sql file will contain a text representation of the database. If you happen to have data in your database, you will see that this data has been exported via COPY.

Note, pg_dump will return data as text. So, all on-board tools of your operating system are at your disposal. Here is how a dump can be compressed easily:

$ pg_dump test | gzip -c > /tmp/dump.sql.gz

Tip

A dump can be done during normal operations. There is no need to shut down the database to extract a dump. Internally, a dump is simply a large transaction in the transaction...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime