# on\_demand\_snapshot

Initiate an on-demand snapshot.

```python
def on_demand_snapshot(object_name, object_type, sla_name='current', fileset=None, host_os=None, sql_host=None, sql_instance=None, sql_db=None, timeout=15)
```

## Arguments

| Name         | Type | Description                                                    | Choices                     |
| ------------ | ---- | -------------------------------------------------------------- | --------------------------- |
| object\_name | str  | The name of the Rubrik object to take a on-demand snapshot of. |                             |
| object\_type | str  | The Rubrik object type you want to backup.                     | vmware, physical\_host, ahv |

## Keyword Arguments

| Name          | Type | Description                                                                                                                   | Choices        | Default |
| ------------- | ---- | ----------------------------------------------------------------------------------------------------------------------------- | -------------- | ------- |
| sla\_name     | str  | The SLA Domain name you want to assign the on-demand snapshot to. By default, the currently assigned SLA Domain will be used. |                | current |
| fileset       | str  | The name of the Fileset you wish to backup. Only required when taking a on-demand snapshot of a physical host.                |                | None    |
| host\_os      | str  | The operating system for the physical host. Only required when taking a on-demand snapshot of a physical host.                | Linux, Windows | None    |
| sql\_host     | str  | The name of the SQL Host hosting the specified database. Only required when taking a on-demand snapshot of a MSSQL DB.        | None           | None    |
| sql\_instance | str  | The name of the SQL Instance hosting the specified database. Only required when taking a on-demand snapshot of a MSSQL DB.    | None           | None    |
| sql\_db       | str  | TThe name of the SQL DB. Only required when taking a on-demand snapshot of a MSSQL DB.                                        | None           | None    |
| timeout       | int  | The number of seconds to wait to establish a connection the Rubrik cluster before returning a timeout error.                  |                | 15      |

## Returns

| Type  | Return Value                                                                                                                                                                                                  |
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tuple | When object\_type is vmware, the full API response for `POST /v1/vmware/vm/{ID}/snapshot` and the job status URL which can be used to monitor progress of the snapshot. (api\_response, job\_status\_url)     |
| tuple | When object\_type is physical\_host, the full API response for `POST /v1/fileset/{}/snapshot` and the job status URL which can be used to monitor progress of the snapshot. (api\_response, job\_status\_url) |

## Example

```python
import rubrik_cdm

rubrik = rubrik_cdm.Connect()

# VMware Snapshot
vsphere_vm_name = "python-sdk-demo"
object_type = "vmware"
snapshot = rubrik.on_demand_snapshot(vsphere_vm_name, object_type)

# AHV Snapshot
ahv_vm_name = "python-sdk-demo"
object_type = "ahv"
snapshot = rubrik.on_demand_snapshot(ahv_vm_name, object_type)

# Physical Host Snapshot
physical_host_name = "python-sdk-physical-demo"
object_type = "physical_host"
sla = "Gold"
fileset = "/etc"
host_os = "Linux"

snapshot = rubrik.on_demand_snapshot(physical_host_name, object_type, sla, fileset, host_os)

# MSSQL DB Snapshot
object_name = "AdventureWorks2014"
object_type = "mssql_db"

snapshot = rubrik.on_demand_snapshot(object_name, object_type, sql_host="hostname.rubrik.com", sql_instance="MSSQLSERVER", sql_db="AdventureWorks2014")
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rubrik.gitbook.io/rubrik-sdk-for-python/documentation_update_api_token/data-management-functions/on_demand_snapshot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
