pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedbackup -restore question
5+ messages / 3 participants
[nested] [flat]
* backup -restore question
@ 2020-07-13 19:12 Julie Nishimura <juliezain@hotmail.com>
2020-07-13 19:32 ` Re: backup -restore question Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 5+ messages in thread
From: Julie Nishimura @ 2020-07-13 19:12 UTC (permalink / raw)
To: pgsql-general; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Hello there,
One of our PostgreSQL 9.4.1 databases has been backed up as *.gz file with the compression 9 "pg_dump -Z 9". What is the right format of restore this file when needed? Can I run the restore from a compressed file or I need to unzip the file first, then run pg_restore? Thanks
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: backup -restore question
2020-07-13 19:12 backup -restore question Julie Nishimura <juliezain@hotmail.com>
@ 2020-07-13 19:32 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-07-13 21:56 ` Re: backup -restore question Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Klaver @ 2020-07-13 19:32 UTC (permalink / raw)
To: Julie Nishimura <juliezain@hotmail.com>; pgsql-general; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
On 7/13/20 12:12 PM, Julie Nishimura wrote:
> Hello there,
> One of our PostgreSQL 9.4.1 databases has been backed up as *.gz file
> with the compression 9 "pg_dump -Z 9". What is the right format of
> restore this file when needed? Can I run the restore from a compressed
> file or I need to unzip the file first, then run pg_restore? Thanks
It depends on whether you dumped using the custom format -Fc or plain(no
-F or -Fp). If the custom format then you run pg_restore against it. If
the plain format then you will to unzip first then feed the file to psql.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: backup -restore question
2020-07-13 19:12 backup -restore question Julie Nishimura <juliezain@hotmail.com>
2020-07-13 19:32 ` Re: backup -restore question Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-07-13 21:56 ` Ron <ronljohnsonjr@gmail.com>
2020-07-14 00:37 ` Re: backup -restore question Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 5+ messages in thread
From: Ron @ 2020-07-13 21:56 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 7/13/20 2:32 PM, Adrian Klaver wrote:
> On 7/13/20 12:12 PM, Julie Nishimura wrote:
>> Hello there,
>> One of our PostgreSQL 9.4.1 databases has been backed up as *.gz file
>> with the compression 9 "pg_dump -Z 9". What is the right format of
>> restore this file when needed? Can I run the restore from a compressed
>> file or I need to unzip the file first, then run pg_restore? Thanks
>
> It depends on whether you dumped using the custom format -Fc or plain(no
> -F or -Fp). If the custom format then you run pg_restore against it. If
> the plain format then you will to unzip first then feed the file to psql.
What about this?
gunzip -c | foo.sql.gz | psql
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: backup -restore question
2020-07-13 19:12 backup -restore question Julie Nishimura <juliezain@hotmail.com>
2020-07-13 19:32 ` Re: backup -restore question Adrian Klaver <adrian.klaver@aklaver.com>
2020-07-13 21:56 ` Re: backup -restore question Ron <ronljohnsonjr@gmail.com>
@ 2020-07-14 00:37 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-07-14 04:18 ` Re: backup -restore question Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Klaver @ 2020-07-14 00:37 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org
On 7/13/20 2:56 PM, Ron wrote:
> On 7/13/20 2:32 PM, Adrian Klaver wrote:
>> On 7/13/20 12:12 PM, Julie Nishimura wrote:
>>> Hello there,
>>> One of our PostgreSQL 9.4.1 databases has been backed up as *.gz
>>> file with the compression 9 "pg_dump -Z 9". What is the right format
>>> of restore this file when needed? Can I run the restore from a
>>> compressed file or I need to unzip the file first, then run
>>> pg_restore? Thanks
>>
>> It depends on whether you dumped using the custom format -Fc or
>> plain(no -F or -Fp). If the custom format then you run pg_restore
>> against it. If the plain format then you will to unzip first then feed
>> the file to psql.
>
> What about this?
> gunzip -c | foo.sql.gz | psql
>
gunzip -c | test_plain.gz | psql -d test_gz -U postgres
bash: test_plain.gz: command not found
gzip: compressed data not read from a terminal. Use -f to force
decompression.
For help, type: gzip -h
Null display is "NULL".
I think what you want is:
gunzip -c test_plain.gz | psql -d test_gz -U postgres
Null display is "NULL".
SET
SET
SET
SET
SET
set_config
------------
(1 row)
SET
SET
SET
SET
CREATE SCHEMA
....
In any case that will only work if the *.gz file is a compressed plain
text format. My suspicion is it is, still I had to allow the possibility
that it is a custom format file that someone hung a gz extension on.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: backup -restore question
2020-07-13 19:12 backup -restore question Julie Nishimura <juliezain@hotmail.com>
2020-07-13 19:32 ` Re: backup -restore question Adrian Klaver <adrian.klaver@aklaver.com>
2020-07-13 21:56 ` Re: backup -restore question Ron <ronljohnsonjr@gmail.com>
2020-07-14 00:37 ` Re: backup -restore question Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-07-14 04:18 ` Ron <ronljohnsonjr@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Ron @ 2020-07-14 04:18 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 7/13/20 7:37 PM, Adrian Klaver wrote:
> On 7/13/20 2:56 PM, Ron wrote:
>> On 7/13/20 2:32 PM, Adrian Klaver wrote:
>>> On 7/13/20 12:12 PM, Julie Nishimura wrote:
>>>> Hello there,
>>>> One of our PostgreSQL 9.4.1 databases has been backed up as *.gz file
>>>> with the compression 9 "pg_dump -Z 9". What is the right format of
>>>> restore this file when needed? Can I run the restore from a compressed
>>>> file or I need to unzip the file first, then run pg_restore? Thanks
>>>
>>> It depends on whether you dumped using the custom format -Fc or plain(no
>>> -F or -Fp). If the custom format then you run pg_restore against it. If
>>> the plain format then you will to unzip first then feed the file to psql.
>>
>> What about this?
>> gunzip -c | foo.sql.gz | psql
>>
>
> gunzip -c | test_plain.gz | psql -d test_gz -U postgres
> bash: test_plain.gz: command not found
> gzip: compressed data not read from a terminal. Use -f to force
> decompression.
> For help, type: gzip -h
> Null display is "NULL".
>
> I think what you want is:
>
> gunzip -c test_plain.gz | psql -d test_gz -U postgres
>
The hazards of not testing code before posting... :)
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-07-14 04:18 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 19:12 backup -restore question Julie Nishimura <juliezain@hotmail.com>
2020-07-13 19:32 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-07-13 21:56 ` Ron <ronljohnsonjr@gmail.com>
2020-07-14 00:37 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-07-14 04:18 ` Ron <ronljohnsonjr@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox