0

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.

1
  • In future please try to mention your exact host OS and version as well as your Pg version. It just saves guesswork. Jul 9, 2013 at 1:58

1 Answer 1

3

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.

3
  • 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, 2013 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, 2013 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". Jul 9, 2013 at 1:06

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .