Generated banner for Cloud SQL Basics
Generated logo for Cloud SQL Basics

Cloud SQL Basics

GoogleOfficialPublished by Google

  • Skill
  • Tool integration
  • Cloud and DevOps
  • Apache-2.0
  • Low risk

From the author

This file generates or explains Cloud SQL resources. Use this file when the user asks to create a Cloud SQL instance or database for MySQL, PostgreSQL, or SQL Server. Cloud SQL manages third-party MySQL, PostgreSQL, and SQL Server instances as resources in Cloud SQL. For example, when Cloud SQL creates an open-source MySQL instance, the resulting resource is a Cloud SQL for MySQL instance that Google Cloud manages. Cloud SQL handles backups, high availability, and secure connectivity for relational database workloads.
— the description by Google

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Cloud SQL Basics provides a structured approach to managing fully managed relational database services on Google Cloud, including MySQL, PostgreSQL, and SQL Server. It covers the lifecycle of database resources, from initial creation and configuration to operational tasks like backups, high availability, and secure connectivity via the Cloud SQL Auth Proxy. The skill emphasizes best practices for resource management, IAM security, and infrastructure-as-code integration.

What it does

  • Provision and configure Cloud SQL instances for MySQL, PostgreSQL, and SQL Server.
  • Manage database users, including IAM-based authentication and static password setup.
  • Perform operational tasks such as creating backups and restoring instances.
  • Retrieve connection details for secure access via the Cloud SQL Auth Proxy.
  • Provide guidance on high availability, read replicas, and read pool configurations.
  • Offer reference material for Terraform integration and client library connectivity.

When to use it

  • When you need to deploy a new managed relational database on Google Cloud.
  • When performing routine administrative tasks like creating databases or managing user access.
  • When setting up secure connectivity between your application and a Cloud SQL instance.
  • When implementing disaster recovery strategies such as backups and point-in-time recovery.
  • When scaling database performance using read replicas or read pools.

Advantages

  • Simplifies complex database management tasks through standardized CLI commands.
  • Ensures secure connectivity patterns by integrating with the Cloud SQL Auth Proxy.
  • Provides clear paths for both manual CLI management and automated infrastructure-as-code.
  • Includes mandatory usage attribution to help track and optimize cloud resource interactions.

Usage examples

“Create a new PostgreSQL instance named my-db-instance in us-central1.”
The agent will execute the gcloud sql instances create command with the specified configuration, enabling the necessary API and setting up the instance.
“How do I connect to my Cloud SQL instance securely?”
The agent will guide you through retrieving the instance connection name and starting the Cloud SQL Auth Proxy to establish a secure connection.
“Create a new database named inventory inside my existing instance.”
The agent will run the gcloud sql databases create command to provision the new database within the specified instance.
“How can I restore my database from a specific backup?”
The agent will provide the gcloud sql backups restore command, explaining how to target either the original or a new instance for the restoration.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/google/cloud-sql-basics/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip cloud-sql-basics.zip -d .agents/skills

Documentation by Google

Cloud SQL Basics

Cloud SQL is a fully managed relational database service for MySQL, PostgreSQL, and SQL Server. It automates time-consuming tasks like patches, updates, backups, and replicas, while providing high performance and availability for your applications.

Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read Usage Attribution. For commands executed directly in the terminal (never in generated scripts, Terraform, or user code), prefix gcloud with CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:cloud-sql-basics)" and append agent-skills/1.0 (skill:cloud-sql-basics) to User-Agent headers.

Prerequisites

Ensure you have the necessary IAM permissions to create and manage Cloud SQL instances. The Cloud SQL Admin (roles/cloudsql.admin) role provides full access to Cloud SQL resources.

Quick Start (PostgreSQL)

  1. Enable the API:

    gcloud services enable sqladmin.googleapis.com --quiet
  2. Create an Instance:

    gcloud sql instances create INSTANCE_NAME \
      --database-version=POSTGRES_18 \
      --cpu=2 \
      --memory=7680MiB \
      --region=REGION \
      --quiet
  3. Set a password for the default user:

    Because this is a Cloud SQL for PostgreSQL instance, the default admin user is postgres:

    gcloud sql users set-password postgres \
      --instance=INSTANCE_NAME --password=PASSWORD \
      --quiet
  4. Create a database:

    gcloud sql databases create DATABASE_NAME \
      --instance=INSTANCE_NAME \
      --quiet
  5. Get the instance connection name:

    You need the instance connection name (which is formatted as PROJECT_ID:REGION:INSTANCE_NAME) to connect using the Cloud SQL Auth Proxy. Retrieve it with the following command:

    gcloud sql instances describe INSTANCE_NAME \
      --format="value(connectionName)" \
      --quiet
  6. Connect to the instance:

    The Cloud SQL Auth Proxy must be running to be able to connect to the instance. In a separate terminal, start the proxy using the connection name:

    ./cloud-sql-proxy INSTANCE_CONNECTION_NAME

    With the proxy running, connect using psql in another terminal:

    psql "host=127.0.0.1 port=5432 user=postgres dbname=DATABASE_NAME password=PASSWORD sslmode=disable"

Reference Directory

  • Core Concepts: Cloud SQL editions (Enterprise & Enterprise Plus), instance architecture, read pools, high availability (HA), and supported database engines.

  • CLI Usage: Essential gcloud sql commands for instance, database, and user management.

  • Client Libraries & Connectors: Connecting to Cloud SQL using Python, Java, Node.js, and Go.

  • MCP Usage: Using the Cloud SQL remote MCP server and Gemini CLI extension.

  • Infrastructure as Code: Terraform configuration for instances, databases, and users.

  • IAM & Security: Predefined roles, SSL/TLS certificates, and Auth Proxy configuration.

  • Disaster Recovery & Backups: Backup types, Point-in-Time Recovery (PITR), replicas, read pools comparison, and Enterprise Plus Advanced DR.

If you need product information not found in these references, use the Developer Knowledge MCP server search_documents tool.

Files

references/dr-backups.md

Cloud SQL Disaster Recovery & Backups

Cloud SQL provides multiple mechanisms for data protection, continuous replication, high availability, and disaster recovery (DR).

Backup Types and Recovery

  • Automated Backups: Daily instance snapshots taken during a user-configurable 4-hour window. Enterprise edition retains up to 7 backups by default; Enterprise Plus edition supports retention up to 35 days.

  • On-Demand Backups: Manually created backups that remain stored until explicitly deleted. Useful before performing high-risk schema migrations or administrative changes.

  • Enhanced Backups: Managed data protection integrated with Google Cloud Backup and DR Service for enterprise governance, centralized management, and compliance across projects.

    • Air-Gapped & Immutable Vaults: Backups are stored in separate, logically isolated projects to protect against ransomware and accidental deletion.

    • Extended Retention & Flexible Schedules: Supports up to 10 years of retention (compared to 1 year for standard backups) with flexible schedules (hourly, daily, weekly, monthly, or yearly).

    • Retention Lock: Enforces non-deletable, non-modifiable backup rules until the specified retention duration expires.

    • Cross-Project Recovery: Facilitates recovery of database workloads into different target projects for disaster recovery operations.

  • Point-in-Time Recovery (PITR): Uses continuous transaction logging (binary logging for MySQL, write-ahead logging for PostgreSQL, transaction logging for SQL Server) to restore an instance to a specific second in time.

    • Retention Limits: Up to 7 days (Enterprise edition) or up to 35 days (Enterprise Plus edition).

    • Storage: Stored on disk or Cloud Storage depending on configuration.

  • Final Backups: Automated final state snapshots taken before instance deletion or post-failover rebuilds to protect data against accidental loss.

  • Backup Locations: Stored by default in the closest multi-region location to the instance, or in custom regional/multi-region storage buckets. Can be restored to the same instance or to a new target instance.

Standard vs. Enhanced Backups
FeatureStandard BackupsEnhanced Backups
ManagementInstance-level Cloud SQL backupsCentralized Backup and DR Service
Storage VaultSame project / multi-region storage bucketSeparate air-gapped immutable backup project
Max RetentionUp to 1 yearUp to 10 years
SchedulingDaily (4-hour configurable window)Hourly, Daily, Weekly, Monthly, Yearly
Retention LockNot supportedSupported (Enforced retention policy)
Cross-Project RecoveryStandard instance restore to project targetsCentralized cross-project recovery workflows
Billing ModelCloud SQL backup storage pricingBackup and DR Service pricing model

Replication Types and High Availability (HA)

  • High Availability (HA) Standby Replicas: Provides regional redundancy with a standby VM situated in a secondary zone within the same region. Employs automatic synchronous replication and instant failover in the event of primary hardware or zonal failure.

  • Standalone Read Replicas: Asynchronous read-only instances (zonal or cross-region) used to scale query traffic and provide local read access.

    • Node Limits: Up to 20 total for MySQL/PostgreSQL; up to 7 for SQL Server.

  • Cascading Replicas: Read replicas that replicate from another read replica rather than directly from the primary instance, reducing replication load on the primary instance.

Advanced Disaster Recovery (DR)

Exclusive to Cloud SQL Enterprise Plus Edition, Advanced DR simplifies regional disaster recovery and drill testing:

  • Designated DR Replica: A cross-region read replica designated as the target for regional recovery operations.

  • Replica Failover: Rapid cross-region failover triggered during primary region outages. Promotes the designated DR replica to primary while retaining the old primary in the replication topology for eventual restoration.

  • Switchover: Zero-data-loss, zero-downtime operation used for planned cross-region failover or routine DR drills. Gracefully reverses roles between the primary instance and the DR replica.

  • DNS Write Endpoints: Provides a global DNS endpoint that automatically shifts write traffic to the newly promoted primary instance following a switchover or replica failover.

Read Pools vs. Read Replicas in Architecture

FeatureStandalone Read ReplicaRead Pool Node
Primary PurposeRead scaling & cross-region DR failover targetHigh-concurrency, load-balanced regional read traffic
TopologyDirect or cascading from primary instanceDirect replication only (no cascading)
Connection EndpointIndividual dedicated IP / Connection nameSingle load-balanced IP / Connection name pool
DR & PromotionCan be promoted to an independent primaryCannot be promoted directly to a primary instance
Scaling MechanismIndividual instance creation/deletionManual scaling or automatic scaling (1-20 nodes)

Disaster Recovery & Backup CLI Management

Backup Management & Operations
  • Enable automated backups and Point-in-Time Recovery (PITR):

    gcloud sql instances patch my-instance \
        --backup-start-time=03:00 \
        --enable-point-in-time-recovery \
        --quiet
  • Create an on-demand backup:

    gcloud sql backups create --instance=my-instance \
        --description="Pre-migration snapshot" \
        --quiet
  • List available backups:

    gcloud sql backups list --instance=my-instance --quiet
  • Restore from a backup:

    • To the original instance (overwrites current data):

      gcloud sql backups restore backup_id --restore-instance=restore-instance --quiet
    • To a different target instance:

      gcloud sql backups restore backup_id \
          --restore-instance=restore-instance \
          --backup-instance=source-instance \
          --quiet
  • Perform Point-in-Time Recovery (PITR Clone): Clones an instance to a new instance state at a specific RFC 3339 timestamp.

    gcloud sql instances clone source-instance restored-instance \
        --point-in-time="2026-07-16T12:00:00Z" \
        --quiet
High Availability & Disaster Recovery Operations
  • Simulate/trigger High Availability (HA) failover: Fail over to the standby instance in the secondary zone for testing.

    gcloud sql instances failover my-ha-instance --quiet
  • Perform planned DR switchover (Enterprise Plus Edition): Executes a zero-data-loss switchover to a designated cross-region DR replica.

    gcloud sql instances switchover my-dr-replica --quiet
  • Promote a read replica to an independent primary:

    gcloud sql instances promote-replica my-replica --quiet

For more information, see:

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs an MCP server, Needs a command-line tool

Security

What our scanner noticed· Low risk

  • Instructions that use the network

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Google
Publisher
Google (Official)
Source
google/skills · skills/cloud/cloud-sql-basics · commit 2194d3b
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Google or Google.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download cloud-sql-basics.zip