Restore from CloudSQL MSSQL backup data
https://cloud.google.com/sql/docs/sqlserver/import-export/import-export-bak#import
# Grant GCS permissions to the CloudSQL service account
Check the service account for your CloudSQL instance
gcloud sql instances describe premisan-test-mssql --project my-project | grep serviceAccountEmailAddress
Add access to GCS bucket
gcloud projects add-iam-policy-binding my-project \
--member "serviceAccount:p123490712340-12345@gcp-sa-cloud-sql.iam.gserviceaccount.com" \
--role "roles/storage.admin"
# restore db from backup file
-> The database to be restored must be run without creating it
gcloud beta sql import bak premisan-test-mssql gs://premisan-test/TestDB_backup_2022_04_24_040001_3056774.bak \
--database=TestDB --project my-project
Command timeout occurs after a certain period of time
Importing data into Cloud SQL instance...failed.
ERROR: (gcloud.beta.sql.import.bak) Operation https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/operations/1234c7dc-1234-1234-1234-f58300001234 is taking longer than expected. You can continue waiting for the operation by running `gcloud beta sql operations wait --project my-project 1234c7dc-1234-1234-1234-f58300001234`
-> Keep waiting for the task to complete
gcloud beta sql operations wait --project my-project 1234c7dc-1234-1234-1234-f58300001234
Output
Waiting for [https://sqladmin.googleapis.com/sql/v1beta4/projects/my-project/operations/1234c7dc-1234-1234-1234-f58300001234]...done.
NAME TYPE START END ERROR STATUS
1234c7dc-1234-1234-1234-f58300001234 IMPORT 2022-04-28T12:29:55.633+00:00 2022-04-28T12:42:29.341+00:00 - DONE
Actual 80GB db data was restored with 10GB backup data
When disk space was insufficient during restoration, disk capacity was automatically increased and restored
'GCP' 카테고리의 다른 글
workload identity federation with k8s cluster (1) | 2023.07.02 |
---|---|
GKE workload identity (0) | 2023.07.01 |
Restoring from a GCP CloudSQL MySQL snapshot (0) | 2023.05.12 |
Setting up a GCP CloudSQL maintenance window (0) | 2023.05.12 |
Create GCP Internal TCP Proxy LB (0) | 2023.05.12 |