Importing cockroach dump files

Hi there,

I am testing out cockraoch’s dump+import feature and running into some issues on the import portion of it. I’ve dumped an existing postgres table using the ckdb command: cockroach dump $CKDB_DB_NAME > $CKDB_DUMP_FILE --certs-dir=$CKDB_CERTS_DIR --dump-mode=data.

Now when I try importing that dump file using the command:
IMPORT PGDUMP 's3://$S3_LOCATION/$CKDB_DUMP_FILE?AWS_ACCESS_KEY_ID=$KEY&AWS_SECRET_ACCESS_KEY=$KEY';

I get the following error back: pq: no table definition found. Does the IMPORT call not support importing files that are dumped with --dump-mode=data?

Thanks!

Hi @Jeongp,

--dump-mode=data will only dump table data. Not including the the table and view schemas.

If you leave this option out during the dump, you will get both and then your import should succeed.

See this .

Let me know if this solves your problem.

Thanks,
Matt

Hi Matt, thanks for the reply!

When importing a dump that includes both the schema and table, does the DB have to be in a fresh state (i.e. no existing schemas that will conflict with the schemas that are included in the dump)?

No problem.

Yes, otherwise i believe the CREATE TABLE statement will run into an error.

If you’d like you can import the table into a different database to work around this.

See this link for a training on using import.

Perfect, I will give this a try :slight_smile:

No problem, let me know if you have other questions.