Re: getting list of tables from command line

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Craig White <craigwhite(at)azapple(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: getting list of tables from command line
Date: 2007-11-02 08:09:20
Message-ID: 20071102080920.GB16757@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Nov 01, 2007 at 08:03:08PM -0700, Craig White wrote:
> *** begin pg_table_dump.scr ***
> #/bin/sh
> #
> # Script to identify tables, backup schema and data separately and
> # then finally, vacuum each table
> #
> DB_NAME=MY_DB
> BACKUP_PATH=/home/backup/postgres/production
> MY_SCHEMA=public
> PG_USER=craig
> #
> psql -U $PG_USER \
> $DB_NAME \
> -c "SELECT tablename FROM pg_tables WHERE \
> schemaname = "\'$MY_SCHEMA\'";" | \
> grep -v 'tablename' | \
> grep -v [\--*] | \
> grep -v rows\) > $BACKUP_PATH/pg_tables

instead of these 3 grep -v, i would suggest to use -qAt switches to
psql:
psql -U $PG_USER -d $DB_NAME -qAt -c "..."

depesz

--
quicksil1er: "postgres is excellent, but like any DB it requires a
highly paid DBA. here's my CV!" :)
http://www.depesz.com/ - blog dla ciebie (i moje CV)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Moiz Kothari 2007-11-02 08:18:34 Re: Number to Words Conversion
Previous Message Scott Marlowe 2007-11-02 06:58:13 Re: young guy wanting (Postgres DBA) ammo