Re: Q: extract database name from directory dump - Mailing list pgsql-general

From Karsten Hilbert
Subject Re: Q: extract database name from directory dump
Date
Msg-id 20160312205908.GD1688@hermes.hilbert.loc
Whole thread Raw
In response to Re: Q: extract database name from directory dump  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Responses Re: Q: extract database name from directory dump  (John R Pierce <pierce@hogranch.com>)
List pgsql-general
On Sat, Mar 12, 2016 at 09:38:13PM +0100, Karsten Hilbert wrote:

> > Not-so-nice solutions coming to mind:
> >
> > - rely on the dump file name
> > - use pg_restore to create an SQL dump
> >   with --create and grep the SQL file
> >   for "create database ..."
> > - restore and compare psql -l output
> >   before/after the fact

Another option that comes to mind is

    pg_restore -l $DUMPDIR | grep dbname: | cut -f 7 -d ' ' -s

but that is quite fragile on the

    -f 7 -d ' '

side of things but that's another question.


Start of pg_restore -l output:

    ;
    ; Archive created at 2016-03-07 21:15:06 CET
    ;     dbname: gnumed_v20
    ;     TOC Entries: 5187
    ;     Compression: 0
    ;     Dump Version: 1.12-0
    ;     Format: DIRECTORY
    ;     Integer: 4 bytes
    ;     Offset: 8 bytes
    ;     Dumped from database version: 9.5.1
    ;     Dumped by pg_dump version: 9.5.1
    ;
    ;
    ; Selected TOC Entries:
    ;
    8525; 1262 181294 DATABASE - gnumed_v20 gm-dbo


Any better suggestions ?

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


pgsql-general by date:

Previous
From: Melvin Davidson
Date:
Subject: Re: Q: extract database name from directory dump
Next
From: Geoff Winkless
Date:
Subject: Re: index problems (again)