histocrat
histocrat

Reputation: 2381

Using CockroachDB's RESTORE command, how can I restore a database into another database name?

I have a backup of a CockroachDB database named foo, and I would like to restore it on my cluster but have the database name be bar. When I try RESTORE DATABASE foo ... WITH into_db=bar, I get an error cannot use "into_db" option when restoring database(s). What's the right way to do this, then?

Upvotes: 1

Views: 634

Answers (1)

histocrat
histocrat

Reputation: 2381

into_db can only be applied at the table level, but there's a simple workaround--apply it to the wildcard expansion of all tables:

RESTORE TABLE foo.* ... WITH into_db=bar

is valid and will do what you want.

In the upcoming 22.1 release, you'll instead be able to do

RESTORE DATABASE foo ... WITH new_db_name=bar -- 22.1+ only

Upvotes: 2

Related Questions