Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 281166326EC for ; Sat, 31 Jan 2009 20:59:49 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 56615-02 for ; Sat, 31 Jan 2009 20:59:45 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by mail.postgresql.org (Postfix) with ESMTP id 1881863264A for ; Sat, 31 Jan 2009 20:59:45 -0400 (AST) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1LTQgY-0007Ry-DK for pgsql-admin@postgresql.org; Sun, 01 Feb 2009 00:59:42 +0000 Received: from 77.70.61.39 ([77.70.61.39]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 01 Feb 2009 00:59:42 +0000 Received: from milen by 77.70.61.39 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 01 Feb 2009 00:59:42 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-admin@postgresql.org From: "Milen A. Radev" Subject: Re: [GENERAL] Encoding problem using pg_dumpall Date: Sun, 01 Feb 2009 02:59:35 +0200 Lines: 58 Message-ID: References: <75E4C42D37E6A74E9FB57C2E9F1300D60107073E@tiger.nexperience.com> <200901292014.29195@zmi.at> <14708.1233277601@sss.pgh.pa.us> <200901301223.49703@zmi.at> <9adabaf40901311547r1444e0c4m4797da5b30671d63@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 77.70.61.39 User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) In-Reply-To: <9adabaf40901311547r1444e0c4m4797da5b30671d63@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.599 tagged_above=0 required=5 tests=RCVD_IN_DNSWL_LOW=-1, RCVD_NUMERIC_HELO=2.599 X-Spam-Level: * X-Archive-Number: 200901/174 X-Sequence-Number: 31221 Cliff Pratt написа: [...] > You should be able to knock up a simple script in bash, perl or python > to do what you want. > > Sort of like: > > Use 'psql' to get a list of the databases > Sanitize the list. > Loop through the list doing backup. > At the end zip them all. > > With a little bit of trickery you should be able to zip them as you go. [...] #!/bin/bash PSQL=/usr/bin/psql PG_DUMP=/usr/bin/pg_dump PG_DUMPALL=/usr/bin/pg_dumpall if [ $# -eq 0 ] ; then BACKUPDIR=/home/db_backup/dumps elif [ $# -ne 1 ] ; then echo -e "Usage: $0 [directory]\n" exit 1 else BACKUPDIR=$1 fi if [ ! -d $BACKUPDIR ] ; then if ! mkdir $BACKUPDIR ; then echo -e "Cannot create backup directory: $BACKUPDIR\n" exit 2 fi fi echo Starting at `date "+%Y-%m-%d %H:%M:%S"` echo -e -n "Dumping globals...\t\t" $PG_DUMPALL -U postgres --globals-only > $BACKUPDIR/pg_globals.sql echo "done." for db in `$PSQL -U postgres -d template1 -t -c "SELECT datname FROM pg_catalog.pg_database WHERE datname "\!"~ 'template(0|1)';"` do echo -n -e "Dumping database $db...\t\t" $PG_DUMP -U postgres --format=c $db > $BACKUPDIR/$db.dump echo "done." done echo Ended at `date "+%Y-%m-%d %H:%M:%S"` [...] -- Milen A. Radev