Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A1691632BF3 for ; Sat, 20 Feb 2010 22:33:55 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 31287-05 for ; Sun, 21 Feb 2010 02:33:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f219.google.com (mail-ew0-f219.google.com [209.85.219.219]) by mail.postgresql.org (Postfix) with ESMTP id D074263161C for ; Sat, 20 Feb 2010 22:33:44 -0400 (AST) Received: by ewy19 with SMTP id 19so1407361ewy.21 for ; Sat, 20 Feb 2010 18:33:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=rTkI5XHBNiYrfl3lhOiRuy3Nk6slRjDKOi8rg1l3r0I=; b=F+8kqHBsltimEpT6+Xu3BzUEaxophplOB00z91zpNqz5S4lF0464uSA6BH5Cs+DRui FNt9RGpAhp6qWMswc5+4MrsHIspqf0x8vEBU0yekNy8MJifboCVVN7GU/bRMUUAacmUq s9A+4znkpEl7su5aX5WrVswFotCTPlWLsCSBA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=skLAcvpqC+Eg46T8DWL7mQZ2cptfdbkNlgdkfzyQgrJVSrG7yY07z7sioEiiWPQJMe EXZBSXUQXB+JcrpHGrnvENx9YM9TqXoPQk2MPZcN9Bhg5w1axPOBxlPiyuGOowYfsmWt IsfFGLsXlAdFA6jpP5aAFoeJJW3nAmYSTsgdU= MIME-Version: 1.0 Received: by 10.216.179.201 with SMTP id h51mr1494874wem.224.1266719622917; Sat, 20 Feb 2010 18:33:42 -0800 (PST) In-Reply-To: <4B809308.6000204@itech7.com> References: <4B8017C0.8070101@itech7.com> <4B809308.6000204@itech7.com> Date: Sat, 20 Feb 2010 19:33:42 -0700 Message-ID: Subject: Re: Backups From: Scott Marlowe To: Nilesh Govindarajan Cc: pgsql-admin@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.473 tagged_above=-10 required=5 tests=AWL=0.126, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201002/164 X-Sequence-Number: 33767 On Sat, Feb 20, 2010 at 6:57 PM, Nilesh Govindarajan wro= te: > On 02/20/2010 11:23 PM, Scott Marlowe wrote: >> >> On Sat, Feb 20, 2010 at 10:11 AM, Nilesh Govindarajan >> =A0wrote: >>> >>> I want a script to backup all databases table by table in different .sq= l >>> files. >> >> Why? =A0It may be that pg_dump / pg_restore already provide the >> functionality you are looking for. >> >>> How to do this ? >> >> pg_dump -t tablename dbname >> >> rinse repeat >> >>> Also since it is a script, there has to be some role having read access >>> to >>> all tables on all databases. How to grant that ? >> >> Can they just be a superuser? =A0Or can you grant them the role that has >> ownership of the tables? > > I don't feel safe to key in the root password in the script. Why would you need to have a password in your script? Just use .pgpass file for whichever unix account is going to connect, and then grant that user the SQL privileges to dump the db. I think you need to do more reading of the docs on user accounts etc under pgsql. > I was previously using MySQL, in which I had a user called backup without > password having SELECT access on all tables and databases. There are lots of ways to attack this, some of which do not require a password to be stored anywhere. At no time should a unix root account be involved. > I need something similar in PgSQL. A possible solution seems to me is to = use > the trust auth for a user in pg_hba.conf, but if the user is given superu= ser > status, then it will have write access to all databases, which is extreme= ly > dangerous. trust auth works but has the issues you mention. the .pgpass file is the easiest way to pass a password without including it in a script or anything. http://www.postgresql.org/docs/8.3/interactive/libpq-pgpass.html Note that the user account in unix doesn't have to map directly to the same name in postgresql.