Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a system with a non-critical postgres database that was unmonitored and consumed all available space on its drive. The OS is unaffected so I am free to delete files.

I would like to just delete the files and reinitialize the database to essentially start from scratch. How can this be done?

I'm running postgres 9.1. The config directories are in /etc/postgres but all of the actual postgres data is in /var/lib/postgres, which is mounted in a different volume group.

share|improve this question

migrated from Jul 11 '13 at 15:35

This question came from our site for professional and enthusiast programmers.

In future please try to mention your exact host OS and version as well as your Pg version. It just saves guesswork. – Craig Ringer Jul 9 '13 at 1:58
up vote 3 down vote accepted

Since you say that the config directories are in /etc/postgres I'm guessing you're running Ubuntu or Debian, which use pg_wrapper for management of their PostgreSQL installs.

On these platforms you use pg_dropcluster to destroy and remove all databases, then pg_createcluster to create a new blank server instance.

This guide for PostgreSQL on Ubuntu may be informative.

share|improve this answer
Hmm so that drops the config files for the cluster to. I think I'd like to wipe the actual data if possible. – Brian Jul 9 '13 at 0:57
Copy the postgresql.conf and pg_hba.conf off to somewhere safe, recreate the cluster, then copy the saved config files back. – bma Jul 9 '13 at 0:59
@Brian bma is quite right: If you wish to retain the config, copy them before you drop the cluster. Rather than copying them back, I'd recommend that you diff them and then edit in only the changes you wish to retain from the old configs to the new ones. That'll make sure you don't keep anything that was "just for testing". – Craig Ringer Jul 9 '13 at 1:06
worked well, thanks guys – Brian Jul 9 '13 at 1:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.