LoginSignup
1

More than 3 years have passed since last update.

シェルスクリプト(gcloud)で cloudsql のバックアップをインポートする

Last updated at Posted at 2019-05-17

メモ。シェルスクリプトで。

op=$(gcloud sql import sql "${dbinstance}" "${gcsuri}" --database="${dbname}" --project="${project}" --quiet --async)
gcloud sql operations wait --project "${project}" --timeout unlimited "${op}"

説明

デフォルトだと300秒でタイムアウトするので、特にバッチ処理とかでやる場合は --async を付けて非同期ジョブにしておく。正常終了したかどうかの確認をするため gcloud sql operations wait で待つ。(確認いらないなら不要だけどまあするよねってことで。) これもほっとくと300秒で待機終了しちゃうので ーーtimeout unlimited を指定する。

ちなみに終わるとこんな感じで何分オペレーションにかかったか教えてくれる。

NAME                                  TYPE    START                          END                            ERROR  STATUS
7937dc37-33ef-4ad2-b380-957cbecf87ce  IMPORT  2019-05-17T08:36:01.591+00:00  2019-05-17T08:37:42.961+00:00  -      DONE

参考URL

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1