From cstearman@infofind.com Fri Nov 22 15:58:47 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0CD67475F25 for ; Fri, 22 Nov 2002 10:58:47 -0500 (EST) Received: from ashdown.infofind.com (infofind.com [216.129.137.2]) by postgresql.org (Postfix) with ESMTP id E3ABA475EB4 for ; Fri, 22 Nov 2002 10:58:44 -0500 (EST) Received: from Colin2000 (ashdown-gw.lightband.com [216.129.135.129]) (authenticated bits=0) by ashdown.infofind.com (8.12.4/8.12.4) with ESMTP id gAMFwmwd016449 for ; Fri, 22 Nov 2002 10:58:48 -0500 Message-ID: <012001c29240$0aae42f0$3301a8c0@Colin2000> From: "Colin Stearman" To: Subject: Database backup and restore Date: Fri, 22 Nov 2002 10:58:45 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_011D_01C29216.206AEF50" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/201 X-Sequence-Number: 6389 This is a multi-part message in MIME format. ------=_NextPart_000_011D_01C29216.206AEF50 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Am I missing something? There seems to be no way to dump all databases an= d then restore them (as you'd have to do on a version change) if the databa= ses contain blobs. pg_dump supports dumping of blobs with the -b -Ft switch, but using pg_dump= all with those switches doesn't seem to work. And in any case, pg_restore = seems to be missing its equivalent pg_restoreall. Other than (painfully) m= anually pg_dumping and pg_restoring each database, how else could it be don= e? I would search the mailing lists but the site's search engine is down. Thanks, Colin --------------------------------------------- Colin Stearman President Ashdown Technologies 119 E. Main St. Milford, MA 01757 USA Tel: +1 508-478-1234 Fax: +1 508-478-1244 www.ashdowntech.com ------=_NextPart_000_011D_01C29216.206AEF50 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Am I missing something?   There = seems to=20 be no way to dump all databases and then restore them (as you'd have to do = on a=20 version change) if the databases contain blobs.
 
pg_dump supports dumping of blobs with the= -b -Ft=20 switch, but using pg_dumpall with those switches doesn't seem to work. = ; And=20 in any case, pg_restore seems to be missing its equivalent pg_restoreall.&n= bsp;=20 Other than (painfully) manually pg_dumping and pg_restoring each database, = how=20 else could it be done?
 
I would search the mailing lists but the s= ite's=20 search engine is down.
 
Thanks,
Colin
---------------------------------------------
Colin=20 Stearman
President
Ashdown Technologies
119 E. Main St.
Milford= , MA=20 01757 USA
Tel: +1 508-478-1234
Fax: +1 508-478-1244
www.ashdowntech.com
------=_NextPart_000_011D_01C29216.206AEF50-- From _pppp@mail.ru Fri Nov 22 16:07:09 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 91D76475B8F for ; Fri, 22 Nov 2002 11:07:09 -0500 (EST) Received: from mx2.mail.ru (mx2.mail.ru [194.67.57.12]) by postgresql.org (Postfix) with ESMTP id 409F447676E for ; Fri, 22 Nov 2002 11:07:08 -0500 (EST) Received: from [213.128.193.142] (helo=mail.ru) by mx2.mail.ru with esmtp (Exim SMTP.2) id 18FGKl-000Dlk-00; Fri, 22 Nov 2002 19:07:12 +0300 Message-ID: <3DDE5628.50403@mail.ru> Date: Fri, 22 Nov 2002 19:07:04 +0300 From: dima <_pppp@mail.ru> User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0.0) Gecko/20020816 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: Colin Stearman Cc: pgsql-admin@postgresql.org Subject: Re: Database backup and restore References: <012001c29240$0aae42f0$3301a8c0@Colin2000> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/202 X-Sequence-Number: 6390 > Am I missing something? There seems to be no way to dump all databases > and then restore them (as you'd have to do on a version change) if the > databases contain blobs. > > pg_dump supports dumping of blobs with the -b -Ft switch, but using > pg_dumpall with those switches doesn't seem to work. And in any case, > pg_restore seems to be missing its equivalent pg_restoreall. Other than > (painfully) manually pg_dumping and pg_restoring each database, how else > could it be done? > > I would search the mailing lists but the site's search engine is down. i wrote a script in perl which dumps all the DBs but template* i can mail it to you if you wish From dan@langille.org Fri Nov 22 19:05:37 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 1C787476332 for ; Fri, 22 Nov 2002 14:05:37 -0500 (EST) Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) by postgresql.org (Postfix) with ESMTP id D02CF47674B for ; Fri, 22 Nov 2002 14:05:29 -0500 (EST) Received: from wocker (wocker.unixathome.org [192.168.0.99]) by bast.unixathome.org (Postfix) with ESMTP id 1F95C3F4B; Fri, 22 Nov 2002 14:05:29 -0500 (EST) From: "Dan Langille" To: dima <_pppp@mail.ru> Date: Fri, 22 Nov 2002 14:05:29 -0500 MIME-Version: 1.0 Subject: Re: Database backup and restore Cc: pgsql-admin@postgresql.org Message-ID: <3DDE39A9.13074.C40F87B6@localhost> In-reply-to: <3DDE5628.50403@mail.ru> X-mailer: Pegasus Mail for Windows (v4.02a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/204 X-Sequence-Number: 6392 On 22 Nov 2002 at 19:07, dima wrote: > i wrote a script in perl which dumps all the DBs but template* > i can mail it to you if you wish Why not post it to the list? That way it's available for everyone. I'm guessing it'll be less than 2K or so... -- Dan Langille : http://www.langille.org/ From murthy.kambhampaty@goeci.com Fri Nov 22 19:40:38 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 167EA4762EE for ; Fri, 22 Nov 2002 14:40:38 -0500 (EST) Received: from THOR.goeci.com (thor.goeci.com [66.28.220.99]) by postgresql.org (Postfix) with ESMTP id 4D5954767FC for ; Fri, 22 Nov 2002 14:40:26 -0500 (EST) Received: by THOR.goeci.com with Internet Mail Service (5.5.2653.19) id ; Fri, 22 Nov 2002 14:40:26 -0500 Message-ID: <2D92FEBFD3BE1346A6C397223A8DD3FC0920A8@THOR.goeci.com> From: Murthy Kambhampaty To: 'dima' <_pppp@mail.ru>, Colin Stearman Cc: pgsql-admin@postgresql.org Subject: Re: Database backup and restore Date: Fri, 22 Nov 2002 14:40:26 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/205 X-Sequence-Number: 6393 In bash, I use: ========== script fragment ========== ~!/bin/bash $BackupDir= $LogFile= for db_name in $(/usr/local/pgsql/bin/psql -U postgres -d template1 -n -t -c "select datname from pg_database where datistemplate='f';"); do /usr/local/pgsql/bin/pg_dump -U postgres -Fc -Z1 -b "$db_name" -f "$BackupDir/$db_name.pgdump" 2>> $LogFile.err && \ echo "$(date +%c): Successfully dumped database $db_name" >> $LogFile done ========== script fragment ========== Cheers, Murthy -----Original Message----- From: dima [mailto:_pppp@mail.ru] Sent: Friday, November 22, 2002 11:07 To: Colin Stearman Cc: pgsql-admin@postgresql.org Subject: Re: [ADMIN] Database backup and restore > Am I missing something? There seems to be no way to dump all databases > and then restore them (as you'd have to do on a version change) if the > databases contain blobs. > > pg_dump supports dumping of blobs with the -b -Ft switch, but using > pg_dumpall with those switches doesn't seem to work. And in any case, > pg_restore seems to be missing its equivalent pg_restoreall. Other than > (painfully) manually pg_dumping and pg_restoring each database, how else > could it be done? > > I would search the mailing lists but the site's search engine is down. i wrote a script in perl which dumps all the DBs but template* i can mail it to you if you wish ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org From cstearman@infofind.com Fri Nov 22 19:41:59 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0F56047675D for ; Fri, 22 Nov 2002 14:41:59 -0500 (EST) Received: from ashdown.infofind.com (infofind.com [216.129.137.2]) by postgresql.org (Postfix) with ESMTP id C068447672A for ; Fri, 22 Nov 2002 14:41:57 -0500 (EST) Received: from Colin2000 (ashdown-gw.lightband.com [216.129.135.129]) (authenticated bits=0) by ashdown.infofind.com (8.12.4/8.12.4) with ESMTP id gAMJfWet015788; Fri, 22 Nov 2002 14:41:36 -0500 Message-ID: <01f901c2925f$2b128e60$3301a8c0@Colin2000> From: "Colin Stearman" To: "Dan Langille" Cc: References: <3DDE39A9.13074.C40F87B6@localhost> Subject: Re: Database backup and restore Date: Fri, 22 Nov 2002 14:41:28 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/206 X-Sequence-Number: 6394 Dan, On first glance at dima's script it does not seem to deal with blobs, although could easily me made to do so. Also it does not address automated reloading. In light of the fact that blobs must be output by -Ft or -Fc in pg_dump, which are tar and custom respectively, the result of an entire db set dump would be one file of this type per database. Maybe the name could be used in a similar reverse-direction script to send each to pg_restore to reload things. I'll be working on it some more and will share what I come up with. It seems a glaring omission that it is impossible to upgrade PostgreSQL across major versions if your database(s) contain blobs (at least, not without a lot of work). Colin ----- Original Message ----- From: "Dan Langille" To: "dima" <_pppp@mail.ru> Cc: Sent: Friday, November 22, 2002 2:05 PM Subject: Re: [ADMIN] Database backup and restore On 22 Nov 2002 at 19:07, dima wrote: > i wrote a script in perl which dumps all the DBs but template* > i can mail it to you if you wish Why not post it to the list? That way it's available for everyone. I'm guessing it'll be less than 2K or so... -- Dan Langille : http://www.langille.org/ ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org From dan@langille.org Fri Nov 22 19:46:16 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 0E5E0475FC4 for ; Fri, 22 Nov 2002 14:46:16 -0500 (EST) Received: from bast.unixathome.org (bast.unixathome.org [66.11.174.150]) by postgresql.org (Postfix) with ESMTP id 4AB08475B8F for ; Fri, 22 Nov 2002 14:46:15 -0500 (EST) Received: from wocker (wocker.unixathome.org [192.168.0.99]) by bast.unixathome.org (Postfix) with ESMTP id 8E96D3F4B; Fri, 22 Nov 2002 14:46:15 -0500 (EST) From: "Dan Langille" To: "Colin Stearman" Date: Fri, 22 Nov 2002 14:46:15 -0500 MIME-Version: 1.0 Subject: Re: Database backup and restore Cc: Message-ID: <3DDE4337.19961.C434DCC6@localhost> In-reply-to: <01f901c2925f$2b128e60$3301a8c0@Colin2000> X-mailer: Pegasus Mail for Windows (v4.02a) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/207 X-Sequence-Number: 6395 On 22 Nov 2002 at 14:41, Colin Stearman wrote: > Dan, > > On first glance at dima's script it does not seem to deal with blobs, > although could easily me made to do so. I think that would be a very good addition to the PostgreSQL toolkit. FWIW, I do not use blobs and consequently do not think of them when backups are required. > I'll be working on it some more and will share what I come up with. I'm sure it will be added to the contrib directory. -- Dan Langille : http://www.langille.org/ From _pppp@mail.ru Mon Nov 25 08:45:10 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B67A2476122 for ; Mon, 25 Nov 2002 03:45:10 -0500 (EST) Received: from mx2.mail.ru (mx2.mail.ru [194.67.57.12]) by postgresql.org (Postfix) with ESMTP id 6B6D74760CD for ; Mon, 25 Nov 2002 03:45:09 -0500 (EST) Received: from drweb by mx2.mail.ru with drweb-scanned (Exim MX.2) id 18GErd-000A5R-00; Mon, 25 Nov 2002 11:45:09 +0300 Received: from [213.128.193.142] (helo=mail.ru) by mx2.mail.ru with esmtp (Exim SMTP.2) id 18GErd-000A1X-00; Mon, 25 Nov 2002 11:45:09 +0300 Message-ID: <3DE1E306.2010209@mail.ru> Date: Mon, 25 Nov 2002 11:44:54 +0300 From: dima <_pppp@mail.ru> User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0.0) Gecko/20020816 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: pgsql-admin@postgresql.org Cc: Dan Langille Subject: Re: Database backup and restore References: <3DDE39A9.13074.C40F87B6@localhost> <01f901c2925f$2b128e60$3301a8c0@Colin2000> Content-Type: multipart/mixed; boundary="------------050005040706010001060306" X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/241 X-Sequence-Number: 6429 This is a multi-part message in MIME format. --------------050005040706010001060306 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit > On first glance at dima's script it does not seem to deal with blobs, > although could easily me made to do so. > > Also it does not address automated reloading. In light of the fact that > blobs must be output by -Ft or -Fc in pg_dump, which are tar and custom > respectively, the result of an entire db set dump would be one file of this > type per database. Maybe the name could be used in a similar > reverse-direction script to send each to pg_restore to reload things. You can easily add -F? option to the script. The result of pg_dump may be piped with gzip for large DBs as well instead of calling the 2nd system(). I don't think blobs are really the problem. The problem i faced before writing the script was to pass the DBA password to pg_dump since i call it from cron. Thanks to Colin's suggestions I improved the script a bit. One can provide the pg_dump options in the beginning of the script as the $pg_dump_options variable (should I move the user name/password & options to a config file?). I added piping as well. I'll add a workaround for huge databases this week probably. --------------050005040706010001060306 Content-Type: text/plain; name="backup.pl" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="backup.pl" #!/usr/bin/perl -w use DBI; my ( $user ) = "user"; my ( $password ) = "password"; my ( $pg_dump_options ) = "-d -O -R"; my ( $path ) = $ARGV[0]; if( !$path || $path eq '' ) { $path = '.'; } chdir( $path ) or die "Can't cd $path: " . $!; my $dbh = DBI->connect( "DBI:Pg:dbname=template1", $user, $password ) || die "Can't connect to the database: " . DBI->errstr; my $sth = $dbh->prepare( "SELECT datname FROM pg_database" ) || die "Can't prepare the query" . $dbh->errstr; $sth->execute || die "Can't execute the query" . $sth->errstr; my ( @data, @databases ); my $count = 0; while( @data = $sth->fetchrow_array() ) { if( !( $data[0] =~ m/template[0,1]/ ) ) { $databases[$count++] = $data[0]; } } $sth->finish; $dbh->disconnect; foreach( @databases ) { my $db = $_; for( 1 .. 6 ) { if( -e "$db.backup." . (7-$_) ) { rename( "$db.backup." . (7-$_), "$db.backup." . (7-$_+1) ); } } if( -e "$db.backup" ) { rename( "$db.backup", "$db.backup.1" ); } system( "export PGUSER=\"$user\"; export PGPASSWORD=\"$password\"; pg_dump $pg_dump_options $_ | gzip > $_.backup" ); } --------------050005040706010001060306-- From _pppp@mail.ru Mon Nov 25 08:58:17 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4BBBF475ED1 for ; Mon, 25 Nov 2002 03:58:17 -0500 (EST) Received: from mx2.mail.ru (mx2.mail.ru [194.67.57.12]) by postgresql.org (Postfix) with ESMTP id E0763475F2B for ; Mon, 25 Nov 2002 03:58:14 -0500 (EST) Received: from [213.128.193.142] (helo=mail.ru) by mx2.mail.ru with esmtp (Exim SMTP.2) id 18GF4I-000IX3-00; Mon, 25 Nov 2002 11:58:14 +0300 Message-ID: <3DE1E61D.8050005@mail.ru> Date: Mon, 25 Nov 2002 11:58:05 +0300 From: dima <_pppp@mail.ru> User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.0.0) Gecko/20020816 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: Dan Langille Cc: Colin Stearman , pgsql-admin@postgresql.org Subject: Re: Database backup and restore References: <3DDE4337.19961.C434DCC6@localhost> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/242 X-Sequence-Number: 6430 >>On first glance at dima's script it does not seem to deal with blobs, >>although could easily me made to do so. > I think that would be a very good addition to the PostgreSQL toolkit. > FWIW, I do not use blobs and consequently do not think of them when > backups are required. > >>I'll be working on it some more and will share what I come up with. > I'm sure it will be added to the contrib directory. Heya, Dan! I posted the script to the list as you asked. Well, restore_all stuff Colin asked for needs some more work since we need to keep owner names somewhere outside the dumps ( I'm not about to parse those dump files ;) ) to restore the DBs with the same owners. I don't think making backups of template? DBs makes sense since they would be unportable between the versions of PostgreSQL. Anyway, restore_all script will be work in progress (I hope I'll have enough free time to contribute this week). Porting dumps between versions of PostgreSQL seems to be a problem. Say, I faced 'serial' type incompatibility moving my dumps from 7.1.3 to 7.2.2 (since they became 64-bit integers). From cstearman@infofind.com Mon Nov 25 22:59:17 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8CCAC475E24 for ; Mon, 25 Nov 2002 17:59:17 -0500 (EST) Received: from ashdown.infofind.com (infofind.com [216.129.137.2]) by postgresql.org (Postfix) with ESMTP id 893D3475D17 for ; Mon, 25 Nov 2002 17:59:11 -0500 (EST) Received: from Colin2000 (ashdown-gw.lightband.com [216.129.135.129]) (authenticated bits=0) by ashdown.infofind.com (8.12.4/8.12.4) with ESMTP id gAPMx0hL001177; Mon, 25 Nov 2002 17:59:01 -0500 Message-ID: <02fa01c294d6$3dfeb4d0$3301a8c0@Colin2000> From: "Colin Stearman" To: "Dan Langille" Cc: References: <3DDE4337.19961.C434DCC6@localhost> Subject: Database backup and restore Date: Mon, 25 Nov 2002 17:58:57 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by amavisd-milter (http://amavis.org/) X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200211/249 X-Sequence-Number: 6437 I have completed the development of a BASH script to dump and load DBs with (or without) blobs. It will dump the globals also, like user names, but I don't know about triggers, etc. As it uses pg_dump and pg_restore to deal with the DBs and pg_dumpall to deal with the globals, it should be all there. You can get the scripts from www.infofind.com/postgreSQL. Although I tested them, NO GUARANTEES OF ANY KIND ARE GIVEN. So test them on something you don't care about first (especially the fullrestore script)! Colin PS. Mail list admin is welcome to add these scripts to the contribution directory, if desired. ----- Original Message ----- From: "Dan Langille" To: "Colin Stearman" Cc: Sent: Friday, November 22, 2002 2:46 PM Subject: Re: [ADMIN] Database backup and restore On 22 Nov 2002 at 14:41, Colin Stearman wrote: > Dan, > > On first glance at dima's script it does not seem to deal with blobs, > although could easily me made to do so. I think that would be a very good addition to the PostgreSQL toolkit. FWIW, I do not use blobs and consequently do not think of them when backups are required. > I'll be working on it some more and will share what I come up with. I'm sure it will be added to the contrib directory. -- Dan Langille : http://www.langille.org/