# Web Cloud › Web Cloud DB › Databases › Copies API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Web Cloud product's sections: https://developers.eu.ovhcloud.com/reference/web-cloud/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 5 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/databases/copies/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/web-cloud/web-cloud-db/databases/copies.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/web-cloud/web-cloud-db/databases/copies.json?format=openapi3

## Operations

- `GET /hosting/privateDatabase/{serviceName}/database/{databaseName}/copy` — List database copies
- `POST /hosting/privateDatabase/{serviceName}/database/{databaseName}/copy` — Create a database copy
- `GET /hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}` — Get a database copy
- `DELETE /hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}` — Delete a database copy
- `POST /hosting/privateDatabase/{serviceName}/database/{databaseName}/copyRestore` — Restore a database copy

## List database copies

`GET /1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/databases/copies/#get-hosting-privatedatabase-servicename-database-databasename-copy

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:database/copy/get`

Returns the IDs of the copies of the database.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `databaseName` | path | string | yes | Database name |
| `serviceName` | path | string | yes | Service name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | string (uuid)[] | successful operation |

```json
[
  "00000000-0000-0000-0000-000000000000"
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy");

print_r($result);
?>
```

## Create a database copy

`POST /1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/databases/copies/#post-hosting-privatedatabase-servicename-database-databasename-copy

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:database/copy/create`

Creates a copy of the database. The copy expires at the expiration date given in the response.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `databaseName` | path | string | yes | Database name |
| `serviceName` | path | string | yes | Service name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | hosting.privateDatabase.Database.Copy | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `creationDate` | string (date-time) | read-only | Creation date of the database copy |
| `expirationDate` | string (date-time) | read-only | Expiration date of the database copy |
| `id` | string (uuid) | read-only | Database copy ID |
| `lastUpdate` | string (date-time) | read-only | Last update of the database copy |
| `status` | hosting.privateDatabase.database.copy.StatusEnum | read-only | Database copy status — one of `doing`, `done`, `error`, `todo` |

```json
{
  "creationDate": "2024-01-01T12:00:00Z",
  "expirationDate": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "lastUpdate": "2024-01-01T12:00:00Z",
  "status": "doing"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.post("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->post("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy");

print_r($result);
?>
```

## Get a database copy

`GET /1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/databases/copies/#get-hosting-privatedatabase-servicename-database-databasename-copy-id

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:database/copy/get`

Returns the status, creation date and expiration date of the copy.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `databaseName` | path | string | yes | Database name |
| `id` | path | string (uuid) | yes | Id |
| `serviceName` | path | string | yes | Service name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | hosting.privateDatabase.Database.Copy | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `creationDate` | string (date-time) | read-only | Creation date of the database copy |
| `expirationDate` | string (date-time) | read-only | Expiration date of the database copy |
| `id` | string (uuid) | read-only | Database copy ID |
| `lastUpdate` | string (date-time) | read-only | Last update of the database copy |
| `status` | hosting.privateDatabase.database.copy.StatusEnum | read-only | Database copy status — one of `doing`, `done`, `error`, `todo` |

```json
{
  "creationDate": "2024-01-01T12:00:00Z",
  "expirationDate": "2024-01-01T12:00:00Z",
  "id": "00000000-0000-0000-0000-000000000000",
  "lastUpdate": "2024-01-01T12:00:00Z",
  "status": "doing"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}");

print_r($result);
?>
```

## Delete a database copy

`DELETE /1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/databases/copies/#delete-hosting-privatedatabase-servicename-database-databasename-copy-id

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:database/copy/delete`

Deletes the copy immediately, before its expiration date. A deleted copy can no longer be restored.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `databaseName` | path | string | yes | Database name |
| `id` | path | string (uuid) | yes | Id |
| `serviceName` | path | string | yes | Service name |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | — | successful operation |

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copy/{id}");

print_r($result);
?>
```

## Restore a database copy

`POST /1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copyRestore`

Link: https://developers.eu.ovhcloud.com/reference/web-cloud/web-cloud-db/databases/copies/#post-hosting-privatedatabase-servicename-database-databasename-copyrestore

**Status:** Stable production version  
**IAM actions:** `webCloudDatabases:apiovh:database/copyRestore`

Restores a copy into the database. The database is not flushed before the restore unless requested.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `databaseName` | path | string | yes | Database name |
| `serviceName` | path | string | yes | Service name |

### Request body (required)

Type: `hosting.privateDatabase.Database.CopyRestorePayload`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `copyId` | string (uuid) | yes | Copy ID |
| `flushDatabase` | boolean |  | Whether to flush the database before restoring the copy (default to false) |

```json
{
  "copyId": "00000000-0000-0000-0000-000000000000",
  "flushDatabase": true
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | hosting.privateDatabase.Task | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `databaseName` | string | read-only | Database name on which the task is working |
| `doneDate` | string (date-time) | read-only | Completion date |
| `dumpId` | integer | read-only | DumpId on which the task is working |
| `function` | hosting.privateDatabase.task.FunctionEnum | read-only | Function name — one of `abuse`, `changeFtpPassword`, `changeRam`, `changeVersion`, `configuration/update`, `create`, `database/copy`, `database/copyRestore`, `database/create`, `database/delete`, `database/dump`, `database/dump/delete`, … |
| `id` | integer | read-only | The id of the task |
| `lastUpdate` | string (date-time) | read-only | Last update |
| `startDate` | string (date-time) | read-only | Task creation date |
| `status` | hosting.privateDatabase.task.StatusEnum | read-only | Task status — one of `cancelled`, `doing`, `done`, `error`, `todo` |
| `userName` | string | read-only | User name on which the task is working |

```json
{
  "databaseName": "string",
  "doneDate": "2024-01-01T12:00:00Z",
  "dumpId": 0,
  "function": "abuse",
  "id": 0,
  "lastUpdate": "2024-01-01T12:00:00Z",
  "startDate": "2024-01-01T12:00:00Z",
  "status": "cancelled",
  "userName": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/hosting/privateDatabase/{serviceName}/database/{databaseName}/copyRestore" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: hosting.privateDatabase.Database.CopyRestorePayload
result = client.post("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copyRestore",
	copyId = None, # Copy ID (type: string)
	flushDatabase = None, # Whether to flush the database before restoring the copy (default to false) (type: boolean)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: hosting.privateDatabase.Database.CopyRestorePayload
$result = $ovh->post("/hosting/privateDatabase/{serviceName}/database/{databaseName}/copyRestore", array(
	copyId => null, // Copy ID (type: string)
	flushDatabase => null, // Whether to flush the database before restoring the copy (default to false) (type: boolean)
));

print_r($result);
?>
```
