본문 바로가기
GCP

Restoring from a GCP CloudSQL MySQL snapshot

by misankim 2023. 5. 12.

Restoring from a GCP CloudSQL MySQL snapshot

 

 

https://cloud.google.com/sql/docs/postgres/backup-recovery/restoring?hl=ko

 

 

# Check backup id

curl -X GET \
-H "Authorization: Bearer "$(gcloud auth print-access-token) \
"https://sqladmin.googleapis.com/v1/projects/my-project-a/instances/premisan-test/backupRuns"

 

 

Output

{
  "kind": "sql#backupRunsList",
  "items": [
    {
      "kind": "sql#backupRun",
      "status": "SUCCESSFUL",
      "enqueuedTime": "2022-09-21T14:53:31.940Z",
      "id": "1234123400000",
      "startTime": "2022-09-21T14:53:31.962Z",
      "endTime": "2022-09-21T14:54:12.634Z",
      "type": "AUTOMATED",
      "windowStartTime": "2022-09-21T14:00:00Z",
      "instance": "premisan-test",
      "selfLink": "https://sqladmin.googleapis.com/v1/projects/my-project-a/instances/premisan-test/backupRuns/1234123400000",
      "location": "asia-northeast3",
      "backupKind": "SNAPSHOT"
    },
    ...
}

 

 

# Restore from a snapshot of another project

-> When restoring from a snapshot, both user information and db information are restored.

 

vim request.json

{
  "restoreBackupContext":
  {
    "backupRunId": 1234123400000,
    "project": "my-project-a",
    "instanceId": "premisan-test"
  }
}

 

 

curl -X POST \
-H "Authorization: Bearer "$(gcloud auth print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://sqladmin.googleapis.com/v1/projects/my-project-b/instances/premisan-test-new/restoreBackup"

 

 

Output

{
  "kind": "sql#operation",
  "targetLink": "https://sqladmin.googleapis.com/v1/projects/my-project-b/instances/premisan-test-new",
  "status": "PENDING",
  "user": "test@example.com",
  "insertTime": "2022-09-21T15:25:48.922Z",
  "operationType": "RESTORE_VOLUME",
  "name": "a4a9ca68-1234-1234-1234-464700000042",
  "targetId": "premisan-test-new",
  "selfLink": "https://sqladmin.googleapis.com/v1/projects/my-project-b/operations/a4a9ca68-1234-1234-1234-464700000042",
  "targetProject": "my-project-b"
}

 

'GCP' 카테고리의 다른 글

GKE workload identity  (0) 2023.07.01
Restore from CloudSQL MSSQL backup data  (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
gcsfuse  (0) 2023.05.12