Context:
I'm automatically installing postgresql-9.1
on an Ubuntu server with apt-get
. This creates the required postgres
user.
The Postgres data is on an external volume that survives reinstalls. This data is obviously owned by the postgres
user.
The problem I'm having is that the ownership is not recorded under the name postgres
, but under the UID that postgres
had at creation time. When the server is reinstalled, postgres
sometimes gets a different UID, and no longer owns the data directory, and thus does not work.
Question:
Can I force the UID of the user postgres
created by apt-get
to something fixed? Or is there another way to solve my problem?
(As you may have deduced, this is on Amazon EC2 with the data on an EBS volume)
Two ideas:
postgres
user before installing PostgreSQL, using the correct UID.chown
.Stole this from here: Lethe's blog
But I actually think that a chown would be better than this, since it cannot fail on account of the
desired_UID
being already used or conflict laden in other ways.I could add a
chown
of the data directory to the server setup script, but I'd prefer a more elegant solution. Also because there are other services, like Tomcat, which have the same problem.