Skip to main content
Glama

create_backup

Generate backups for GCP Cloud SQL instances by specifying the project ID, instance ID, and optional description. Ensures data recovery and continuity for Google Cloud databases.

Instructions

    Create a backup for a Cloud SQL instance.
    
    Args:
        project_id: The ID of the GCP project
        instance_id: The ID of the Cloud SQL instance
        description: Optional description for the backup
    
    Returns:
        Result of the backup operation
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNo
instance_idYes
project_idYes

Implementation Reference

  • The create_backup tool handler: creates an on-demand backup for a Cloud SQL instance using the GCP SQL Admin API.
        @mcp.tool()
        def create_backup(project_id: str, instance_id: str, description: Optional[str] = None) -> str:
            """
            Create a backup for a Cloud SQL instance.
            
            Args:
                project_id: The ID of the GCP project
                instance_id: The ID of the Cloud SQL instance
                description: Optional description for the backup
            
            Returns:
                Result of the backup operation
            """
            try:
                from googleapiclient import discovery
                
                # Initialize the Cloud SQL Admin API client
                service = discovery.build('sqladmin', 'v1')
                
                # Create backup
                backup_run_body = {}
                if description:
                    backup_run_body['description'] = description
                
                request = service.backupRuns().insert(project=project_id, instance=instance_id, body=backup_run_body)
                operation = request.execute()
                
                # Get operation ID and status
                operation_id = operation.get('name', 'Unknown')
                status = operation.get('status', 'Unknown')
                
                return f"""
    Backup operation initiated:
    - Instance: {instance_id}
    - Project: {project_id}
    - Description: {description or 'None provided'}
    
    Operation ID: {operation_id}
    Status: {status}
    
    The backup process may take some time to complete. You can check the status of the backup using the Cloud SQL Admin API or Google Cloud Console.
    """
            except Exception as e:
                return f"Error creating backup: {str(e)}"
  • Registers the databases tools module, which contains the create_backup handler, with the MCP server instance.
    databases_tools.register_tools(mcp)

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/henihaddad/gcp-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server