Take the 2-minute tour ×
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. It's 100% free, no registration required.

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 stackoverflow.com 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

1 Answer 1

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
1  
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

 
discard

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.