Scorb
Scorb

Reputation: 1920

How do I use gcloud sql operation wait?

I am looking at the documentation for this command.

It says that it requires the operation identifier...

An identifier that uniquely identifies the operation

But it does not give an example of how to obtain an identifier. What am I supposed to provide for this value? I am a getting an error when creating an sql instance using gcloud because I did not wait, and I don't know how to use this command from the docs description of it.

Upvotes: 2

Views: 1976

Answers (1)

Edgar
Edgar

Reputation: 143

I was having the same issue. Here is essential how you use this guy:

gcloud sql import sql qa-1 gs://db_dumps/staging/Cloud_SQL_Export_$(date +%F).sql --database=qa-1 --async --quiet
sleep 10
PENDING_OPERATION=$(gcloud sql operations list --instance=qa-1 --filter="TYPE:IMPORT AND NOT STATUS:DONE" --format='value(name)')
gcloud sql operations wait "$PENDING_OPERATION" --timeout=unlimited

Notice the use of async. If you wait for that command to fail your in trouble because its going to. Instead, run the command asynchronously, look up the operation id using filters, store it, and then use the wait command with that id.

Then, Party!

Upvotes: 9

Related Questions