Cloudsql delete instance restore buckup - ghdrako/doc_snipets GitHub Wiki
gcloud sql instances create [INSTANCE_NAME] --deletion-protection
gcloud sql instances patch [INSTANCE_NAME] --no-deletion-protection
All data on an instance, including backups, is permanently lost when that instance is deleted. To preserve your data, export it to Cloud Storage before you delete it.
gcloud sql instances delete INSTANCE_NAME --project=PROJECT_ID
- https://issuetracker.google.com/issues/203852777?pli=1 On-demand backup jest kasowany po skasowaniu instancji tak jak inne bacupy automatyczne!!!
gcloud sql backups create --async --instance=INSTANCE_NAME [--location=BACKUP_LOCATION] [--description="opis"]
gcloud sql import sql INSTANCE URI [--async]
[--database=DATABASE, -d DATABASE] [--user=USER] [GCLOUD_WIDE_FLAG …]
gcloud sql backups list --instance INSTANCE_NAME
gcloud sql backups describe BACKUP_ID --instance INSTANCE_NAME
- https://geko.cloud/en/gcp-cloud-sql-recover-database/
- https://www.googlecloudcommunity.com/gc/Databases/Can-t-restore-backup-from-deleted-postgres-database/td-p/495720
- name: Restore snapshot of temp instance to staging instance
run: |
echo STAGING_RESTORE_OPERATION_NAME=$(curl -sS -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d '{"restoreBackupContext":{"backupRunId": ${{ env.TEMP_INSTANCE_LAST_BACKUP_ID }},"project": "${{ env.TEMP_INSTANCE_PROJECT }}","instanceId": "${{ env.TEMP_INSTANCE_NAME }}"}}' \
"https://sqladmin.googleapis.com/v1/projects/${{ env.STAGING_INSTANCE_PROJECT }}/instances/${{ env.STAGING_INSTANCE_NAME }}/restoreBackup" | jq -r .name) >> $GITHUB_ENV
- name: Wait for database restore staging instance operations to finish
run: gcloud sql operations wait ${{ env.STAGING_RESTORE_OPERATION_NAME }} --project=${{ env.STAGING_INSTANCE_PROJECT }} --timeout=1200 --quiet
Short time after delete instance is posible to restore from backup
gcloud sql backups list --instance=deleted-db-name --project your-project-name
gcloud sql backups restore <backup-ID> --restore-instance=new-db-from-scratch-name --project your-project