Re: Q: extract database name from directory dump

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Q: extract database name from directory dump
Date: 2016-03-12 21:28:06
Message-ID: 20160312212806.GH1688@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Mar 12, 2016 at 04:17:07PM -0500, Melvin Davidson wrote:

> BTW, other than the obvious of including the name in path or file, if you
> are referring to previous/existing dumps

I do.

> grep -i some_dump_file 'CREATE DATABASE'

That will not work (directly) because the dump is in
directory format.

> If nothing is found, then the dump can be applied to ANY database.

Since one can create an SQL dump from the directory dump the
above becomes possible by appropriate use of

pg_restore -C ... | grep CREATE DATABASE

This is, indeed, the option (after pg_restore -l | grep ...)
I consider least fragile.

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Ruprecht 2016-03-12 21:33:01 Re: OS X 10.11.3, psql, bus error 10, 9.5.1
Previous Message Karsten Hilbert 2016-03-12 21:19:49 Re: Q: extract database name from directory dump