Bacula-users

Re: [Bacula-users] PG database error

2009-04-08 10:33:36
Subject: Re: [Bacula-users] PG database error
From: Tom Plancon <tplancon AT bkaarchs DOT com>
To: Craig Ringer <craig AT postnewspapers.com DOT au>
Date: Wed, 08 Apr 2009 10:34:00 -0400
Craig,

Thanks for the response. I altered all the tables to owner "bacula", ran catalogbackup and got the same error:

08-Apr 10:04 p-plover-dir JobId 5: BeforeJob: pg_dump: Error message from server: ERROR: permission denied for relation contact_userid_seq

So I went in to the db via phpPgAdmin and checked the sequences. I had been mucking around in the db changing permissions/owners a bit haphazardly before I got your response. Sure enough, some of the sequences where owned by another user even though all the bacula tables were owned by bacula. Corrected that and now all is well!

Thanks again for the help and your clear and complete explanation! Very helpful!

Craig Ringer wrote:
T. Plancon wrote:
Hello,

I'm setting up bacula 2.4.2 on a CentOS 5 system using postgresql as the
db. I've used the scripts in /usr/lib/bacula, running as user
'postgres'

Whoops. You should create the tables under user `bacula' if that's the user ID your director runs under.

create_postgresql_database, make_postgresql_tables,
grant_postgresql_privileges in that order. An initial backup ran fine,
but I got this error when doing the catalog backup:

07-Apr 14:00 p-plover-dir JobId 1: BeforeJob: run command "/usr/lib/bacula/make_catalog_backup bacula bacula"
07-Apr 14:00 p-plover-dir JobId 1: BeforeJob: pg_dump: SQL command failed
07-Apr 14:00 p-plover-dir JobId 1: BeforeJob: pg_dump: Error message from server: ERROR:  permission denied for relation contact_userid_seq

If you connect to the database `bacula' as user `postgres' (usually:
    sudo su postgres -c "psql bacula"
) and run:
    \dt+
you'll probably find that the tables are owned by a user other than `bacula' - in your case, `postgres'.

I landed up with a database where Bacula had been GRANTed SELECT, INSERT, UPDATE and DELETE rights, but didn't have the right to LOCK tables, so pg_dump would fail when run as user `bacula' by the director. You probably have related rights issues.

To resolve this, just:

    ALTER TABLE tablename OWNER TO bacula;

after connecting to the database as user `postgres' (since that'll be the current owner in your case).

Unfortunately, Pg offers no way to recursively change ownership. Either script it, or just enter the tables by hand; there aren't that many.

IMO, the make_postgreql_tables SQL script really needs to `\c - bacula' (or "\c - ${bacula_user}" ... whatever) to ensure that it creates the tables with appropriate ownership.

--
Craig Ringer


--
myEMAILsignature Thomas E. Plancon
CAD/IS Manager

B K A Architects, Inc.
142 Crescent Street
Brockton, MA 02302

tel: 508 . 583 . 5603 ext 313
fax: 508 . 584 . 2914
www.bkaarchitects.com
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users
<Prev in Thread] Current Thread [Next in Thread>