Skip to content

create_db_snapshot

create_db_snapshot(
    *,
    config_overrides: Optional[RDSClientConfig] = None,
    db_snapshot_identifier: Optional[String] = None,
    db_instance_identifier: Optional[String] = None,
    tags: Optional[TagList] = None,
) -> CreateDBSnapshotResult

Creates a snapshot of a DB instance. The source DB instance must be in the available or storage-optimization state.

Parameters:

  • db_snapshot_identifier (Optional[String], default: None ) –

    The identifier for the DB snapshot.

    Constraints:

    • Can't be null, empty, or blank

    • Must contain from 1 to 255 letters, numbers, or hyphens

    • First character must be a letter

    • Can't end with a hyphen or contain two consecutive hyphens

    Example: my-snapshot-id

  • db_instance_identifier (Optional[String], default: None ) –

    The identifier of the DB instance that you want to create the snapshot of.

    Constraints:

    • Must match the identifier of an existing DBInstance.

Raises:

Examples:

To create a DB snapshot The following example creates a DB snapshot.

>>> client.create_db_snapshot(db_snapshot_identifier='database-mysql', db_instance_identifier='mydbsnapshot')
Source code in docs_src/capo_rds/_services/rds.py
def create_db_snapshot(
    self,
    *,
    config_overrides: Optional[RDSClientConfig] = None,
    db_snapshot_identifier: Optional["capo_rds.types.string.String"] = None,
    db_instance_identifier: Optional["capo_rds.types.string.String"] = None,
    tags: Optional["capo_rds.types.tag_list.TagList"] = None,
) -> "capo_rds.types.create_db_snapshot_result.CreateDBSnapshotResult":
    """<p>Creates a snapshot of a DB instance. The source DB instance must be in the <code>available</code> or <code>storage-optimization</code> state.</p>

    Args:
        db_snapshot_identifier: <p>The identifier for the DB snapshot.</p> <p>Constraints:</p> <ul> <li> <p>Can't be null, empty, or blank</p> </li> <li> <p>Must contain from 1 to 255 letters, numbers, or hyphens</p> </li> <li> <p>First character must be a letter</p> </li> <li> <p>Can't end with a hyphen or contain two consecutive hyphens</p> </li> </ul> <p>Example: <code>my-snapshot-id</code> </p>
        db_instance_identifier: <p>The identifier of the DB instance that you want to create the snapshot of.</p> <p>Constraints:</p> <ul> <li> <p>Must match the identifier of an existing DBInstance.</p> </li> </ul>

    Raises:
        capo_rds.errors.db_instance_not_found_fault.DBInstanceNotFoundFault: <p> <code>DBInstanceIdentifier</code> doesn't refer to an existing DB instance.</p>
        capo_rds.errors.db_snapshot_already_exists_fault.DBSnapshotAlreadyExistsFault: <p> <code>DBSnapshotIdentifier</code> is already used by an existing snapshot.</p>
        capo_rds.errors.invalid_db_instance_state_fault.InvalidDBInstanceStateFault: <p>The DB instance isn't in a valid state.</p>
        capo_rds.errors.snapshot_quota_exceeded_fault.SnapshotQuotaExceededFault: <p>The request would result in the user exceeding the allowed number of DB snapshots.</p>
        capo_rds.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a DB snapshot
        The following example creates a DB snapshot.

        >>> client.create_db_snapshot(db_snapshot_identifier='database-mysql', db_instance_identifier='mydbsnapshot')
    """

    def _handler(
        req: "OperationRequest[capo_rds.types.create_db_snapshot_message.CreateDBSnapshotMessage]",
    ) -> OperationResponse[
        "capo_rds.types.create_db_snapshot_result.CreateDBSnapshotResult"
    ]:
        import capo_rds._operations.amazon_rd_sv19.create_db_snapshot

        output, http_response = (
            capo_rds._operations.amazon_rd_sv19.create_db_snapshot.create_db_snapshot(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateDBSnapshot")
    )
    input_: capo_rds.types.create_db_snapshot_message.CreateDBSnapshotMessage = {}
    if db_snapshot_identifier is not None:
        input_["db_snapshot_identifier"] = db_snapshot_identifier
    if db_instance_identifier is not None:
        input_["db_instance_identifier"] = db_instance_identifier
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output