pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Mariel Cherkassky <mariel.cherkassky@gmail.com>
To: pgsql-admin@lists.postgresql.org
Subject: Re: pg_restore fails to restore sequence of specific table
Date: Sun, 17 Feb 2019 20:31:14 +0100
Message-ID: <41dbc1307b3ebe4c9251194f5f380ca44cc8dc66.camel@cybertec.at> (raw)
In-Reply-To: <CA+t6e1kJjaLL=o6XfVVZRdKg9GPU=ntXHug6dCgEAQa5r7vgYw@mail.gmail.com>
References: <CA+t6e1kJjaLL=o6XfVVZRdKg9GPU=ntXHug6dCgEAQa5r7vgYw@mail.gmail.com>

Mariel Cherkassky wrote:
> I have a backup of an entire db(9.2.5) that was taken with the next command : 
> pg_dump -U postgres -Fc my_db > mydb.dump
> 
> Now, I'm trying to restore a specific table (with its sequence) but I'm getting the following error error:
> pg_restore -d mydb -U postgres -v -t specific_table mydb.dump
> output : 
> pg_restore: connecting to database for restore
> Password:
> pg_restore: creating TABLE specific_table
> pg_restore: [archiver (db)] Error while PROCESSING TOC:
> pg_restore: [archiver (db)] Error from TOC entry 241; 1259 4236973 TABLE specific_table postgres
> pg_restore: [archiver (db)] could not execute query: ERROR:  relation "specific_table_id_seq" does not exist
>     Command was: CREATE TABLE specific_table(
>     id integer DEFAULT nextval('specific_id_seq'::regclass) NOT NULL,
>     effectiveid integer DEFAULT ...
> pg_restore: [archiver (db)] could not execute query: ERROR:  relation "public.specific_table" does not exist
>     Command was: ALTER TABLE public.specific_table OWNER TO postgres;

You have to restore the sequence as well:

pg_restore -t specific_table -t specific_table_id_seq ...

> I tried to generate a plain text from the dump : 
> pg_restore -U postgres -t specific mydb.dump > output
> However, the output file doesnt contain the creation command of the sequence.

Well, it isn't called "specific", is it?

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com





view thread (5+ messages)  latest in thread

Message-ID: <41dbc1307b3ebe4c9251194f5f380ca44cc8dc66.camel@cybertec.at>
Permalink:  ../41dbc1307b3ebe4c9251194f5f380ca44cc8dc66.camel@cybertec.at/
Also on:    postgresql.org/message-id/41dbc1307b3ebe4c9251194f5f380ca44cc8dc66.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: laurenz.albe@cybertec.at, mariel.cherkassky@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: Re: pg_restore fails to restore sequence of specific table
  In-Reply-To: <41dbc1307b3ebe4c9251194f5f380ca44cc8dc66.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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