Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 8E89D633442 for ; Sat, 20 Feb 2010 22:05:49 -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 27501-03 for ; Sun, 21 Feb 2010 02:05:30 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail-vw0-f46.google.com (mail-vw0-f46.google.com [209.85.212.46]) by mail.postgresql.org (Postfix) with ESMTP id ED88B6332E8 for ; Sat, 20 Feb 2010 22:05:38 -0400 (AST) Received: by mail-vw0-f46.google.com with SMTP id 11so520200vws.19 for ; Sat, 20 Feb 2010 18:05:37 -0800 (PST) Received: by 10.220.122.210 with SMTP id m18mr5944213vcr.94.1266717455353; Sat, 20 Feb 2010 17:57:35 -0800 (PST) Received: from ?192.168.1.254? ([121.246.205.20]) by mx.google.com with ESMTPS id 28sm2578701vws.11.2010.02.20.17.57.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 20 Feb 2010 17:57:34 -0800 (PST) Message-ID: <4B809308.6000204@itech7.com> Date: Sun, 21 Feb 2010 07:27:28 +0530 From: Nilesh Govindarajan User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20100120 Shredder/3.0.1 MIME-Version: 1.0 To: Scott Marlowe CC: pgsql-admin@postgresql.org Subject: Re: Backups References: <4B8017C0.8070101@itech7.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=-10 required=5 tests=BAYES_50=0.001 X-Spam-Level: X-Archive-Number: 201002/162 X-Sequence-Number: 33765 On 02/20/2010 11:23 PM, Scott Marlowe wrote: > On Sat, Feb 20, 2010 at 10:11 AM, Nilesh Govindarajan wrote: >> I want a script to backup all databases table by table in different .sql >> files. > > Why? It 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? Or 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. I was previously using MySQL, in which I had a user called backup without password having SELECT access on all tables and databases. 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 superuser status, then it will have write access to all databases, which is extremely dangerous. -- Nilesh Govindarajan Site & Server Adminstrator www.itech7.com