HeatWare.net header image
HeatWare.net
TwitterRSSEmail
  • Home
  • Windows
    • Windows 8
    • Windows 7
    • Windows Vista
    • Windows XP
  • Linux/Unix
  • Mac
  • Mobile
    • Android
    • iOS
    • Phones (Help / Resources)
  • Software / Programming
    • Free Software
    • Programming – General
    • PHP
    • Ruby/Rails
    • Quality Assurance (QA)
    • Software – General
    • Software Help
    • Databases
  • Cool Websites
  • Other
    • Deals & Bargains
    • News
    • Video Games
    • Hardware
    • Electronics
  • About

2 comments / April 29, 2012 / sood / Databases

How to backup/dump a PostgreSQL database using pg_dump

This article will show you how to use the pg_dump utility that is built-in to PostgreSQL to backup or dump the database to a file. This is a utility I use all the time to quickly make periodic backups of my databases. This tool has the ability to create both compressed and uncompressed dumps of your database. So if you have a small database, you should be OK using the uncompressed version, which is easily human-readable. However, for large databases  it will be optimal to use the compressed formats. Below are some examples:

Create Non-compressed PostgreSQL Database Backup

pg_dump -U <DB Username> <DB Name> > backup.sql

Create Compressed PostgreSQL Database Backup

pg_dump -U <DB Username> <DB Name> -Fc > backup.dump

Create a Schema-only PostgreSQL Database Backup

In some cases, you are not interested in backing up all of the Data in the database and only want to backup the schema (tables, indexes, triggers, etc). This is done by using the -s option.

pg_dump -U <DB Username> <DB Name> -s > schema.sql

Coming soon, we will show you how to restore the database using these dumps

Related Posts

  • Create a compressed MySQL database dump/backup (Linux)
  • Find PostgreSQL database size using SQL 'Select'
  • pgAdmin - PostgreSQL GUI Management Tool
  • How to install PostgreSQL 8.4 on CentOS 5.5
  • PostgreSQL: How to reload config settings without restarting database

Databases Postgres PostgreSQL

2 comments… add one
  1. praveen kumar June 14, 2012, 3:37 am

    hi guys can u pls help me how to take backup of postgres databses by step by step procedure it is needful for me

  2. Mr.Olek September 12, 2016, 5:09 am

    Hi PRAVEEN KUMAR,
    You can simply use PostgreSQL-Backup tool to backup your Postgres database. Chech it out postgresql-backup . com

Cancel reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Why You Should Consider Diving Apps
  • How to Buy a Smartphone that Fits Your Budget
  • How to Overcome Frustrating PDF Stress
  • Convert PDF to Word: Easy, Reliable and Quality Conversion
  • PDF to Excel App ­ – A New Way of Handling Tricky Documents

Recent Comments

  • Valarie Walter on Basic Troubleshooting Steps for your Cell Phone
  • John Mists on A Brief History of Android OS
  • syarif on PostgreSQL: How to reload config settings without restarting database
  • Raghu on How to SSH to a server using Ruby – Part I
  • francisco clemente on Basic Troubleshooting Steps for your Cell Phone

Tags

ACSLS Android Bargain Cell Phones Cool Software Cool Websites Databases Deals Ebooks Facebook Free Software G2x Galaxy S5 iOS iPhone Kindle LG Linux Linux/Unix Mac Mobile mysql Office OpenStack OS X PHP Postgres PostgreSQL ruby Samsung Galaxy S6 Shell Smartphones Sun T-Mobile Tips Tips & Tricks Ubuntu Unix Virtualization VMWare Windows Windows 7 Windows 8 Windows Vista Windows XP

Latest Tweet

Follow @HeatwaredotNet

SP
@HeatwaredotNet

  • Why You Should Consider Diving Apps https://t.co/Is41cdUv2I #diving-apps
    about 6 years ago

All Categories

Other Links

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Copyright © 2015 — HeatWare