You are not logged in.

#1 2010-11-28 23:58:48

Bushman
Member
Registered: 2010-05-27
Posts: 32

PostgreSQL data directory [SOLVED]

I had a rather major Syu recently, and I had to manually re-install python. I ran out of space on my root filesystem while it was installing the updated packages, so I had to do a cache cleanup and then restart the update. Unfortunately, PostgreSQL also had a major version update (8.4 -> 9.0.1), and the cache cleanup removed the previous version of it. I looked through the log files as suggested after reinstalling, finding that the data directory was incompatible with the new version. Thankfully, the only thing I had that was actually using it (a work-in-progress web2py application) did not and does not have any data in it (yet, I hope), so I thought, "hey, reinstalling it ought to regenerate that directory with the factory defaults if it's missing, right?" Wrong, or so I found out after I reinstalled the "postgresql" package and "rm -Rf"-ed the data directory, which included the configuration files. Googling for the default configuration files did not help.
How does Pacman know when to create the data directory, and how do I make it do so?

Last edited by Bushman (2010-11-29 10:58:40)

Offline

#2 2010-11-29 06:00:57

foutrelis
Developer
From: Athens, Greece
Registered: 2008-07-28
Posts: 705
Website

Re: PostgreSQL data directory [SOLVED]

The /etc/rc.d/postgresql script is the one that creates the data directory if it doesn't exist. If you open it in a text editor, you'll see that it contains the following part:

if [ ! -d $PGROOT ]; then
  mkdir -p $PGROOT/data && chown -R postgres.postgres $PGROOT
  su - postgres -c "/usr/bin/initdb $INITOPTS -D $PGROOT/data"
fi

PGROOT is set to "/var/lib/postgres" in /etc/conf.d/postgresql.

So, if you don't care about the existing databases, you can remove the /var/lib/postgres directory and restart the PostgreSQL server. smile

Offline

#3 2010-11-29 10:58:22

Bushman
Member
Registered: 2010-05-27
Posts: 32

Re: PostgreSQL data directory [SOLVED]

It worked, thank you so much! For some reason, I didn't think to look in the init script.

Offline

Board footer

Powered by FluxBB