# Backups

> Source: https://developers.cloud66.com/v3/endpoints/backups/

## Get Backup

URL: https://developers.cloud66.com/v3/endpoints/backups/#get
Endpoint: GET /stacks/:stack_id/backups/:id
OAuth scope: public

Get information about a single backup.

**Related models:** Backup

### Parameters

- `stack_id` (string, required) — The stack UID
- `id` (integer, required) — Backup ID

### Response

```json
{
  "response":
    {
      "id":1,
      "server_uid":"e63e859d5ab72b0bcf14321f0ffb013d",
      "db_type":"mysql",
      "database_name":"shab-test-db",
      "file_base":"",
      "backup_date_iso":"2014-09-01T18:16:16Z",
      "backup_status":0,
      "backup_result":"",
      "restore_status":0,
      "restore_result":null,
      "created_at_iso":"2014-09-01T18:16:16Z",
      "updated_at_iso":"2014-09-01T18:16:16Z",
      "verify_status":0,
      "verify_result":null,
      "storage_path":"2aad2bb5a70e621ecf251fbd85af6927/backups/3c656a1bcc160769762763c6276c18b9/mysql/test_db_11/2014.09.01.18.16.14",
      "skip_tables":"",
      "backup_size":0
    }
}
```

---

## Get Backup File

URL: https://developers.cloud66.com/v3/endpoints/backups/#file-get
Endpoint: GET /stacks/:stack_id/backups/:backup_id/files/:id
OAuth scope: public

Get the public URL to a backup file.

**Related models:** Backup

### Parameters

- `stack_id` (string, required) — The stack UID
- `backup_id` (integer, required) — Backup ID
- `id` (string, required) — The file ID

### Response

```json
{
  "response":
    {
      "ok":true,
      "public_url":"https://c66-managed-backup-non-prod.s3.amazonaws.com/2aad2bb5a70e621ecf251fbd85af6927/backups/3c656a1bcc160769762763c6276c18b9/mysql/test_db_11/2014.09.01.18.16.14/test_db_11.tar?AWSAccessKeyId=AKIAIKCYITLQBEJDIETQ\u0026Expires=1409603570\u0026Signature=C2au7Jq%252F1m6uHGHRfGJPn%252F2GSS8%253D"
    }
}
```

---

## List Backup Files

URL: https://developers.cloud66.com/v3/endpoints/backups/#files-list
Endpoint: GET /stacks/:stack_id/backups/:backup_id/files
OAuth scope: public

Get list of all backup files of a stack.

**Related models:** Backup, Pagination

### Parameters

- `stack_id` (string, required) — The stack UID
- `backup_id` (integer, required) — Backup ID

### Response

```json
{
  "response":[
    {
      "id":"tar",
      "name":"test_db_11.tar"
    }
  ],
  "count":1,
  "pagination":
    {
      "previous":null,
      "next":null,
      "current":1,
      "per_page":30,
      "count":1,
      "pages":1
    }
}
```

---

## List Backups

URL: https://developers.cloud66.com/v3/endpoints/backups/#list
Endpoint: GET /stacks/:id/backups
OAuth scope: public

Get list of all backups of stack.

**Related models:** Backup, Pagination

### Parameters

- `id` (string, required) — The stack UID
- `group` (integer, optional) — Backup group ID
- `db_type` (string, optional) — Backup database type (valid options are: mysql, postgresql, redis, mongodb)

### Response

```json
{
  "response":[
    {
      "id":4,
      "server_uid":"e63e859d5ab72b0bcf14321f0ffb013d",
      "db_type":"mysql",
      "database_name":"test-db",
      "file_base":"",
      "backup_date_iso":"2014-09-01T19:00:33Z",
      "backup_status":0,
      "backup_result":"",
      "restore_status":0,
      "restore_result":null,
      "created_at_iso":"2014-09-01T19:00:33Z",
      "updated_at_iso":"2014-09-01T19:00:33Z",
      "verify_status":0,
      "verify_result":null,
      "storage_path":"2aad2bb5a70e621ecf251fbd85af6927/backups/3c656a1bcc160769762763c6276c18b9/mysql/test_db_11/2014.09.01.19.00.31",
      "skip_tables":"","backup_size":0
    },
    {
      "id":1,
      "server_uid":"e63e859d5ab72b0bcf14321f0ffb013d",
      "db_type":"mysql",
      "database_name":"test-db",
      "file_base":"",
      "backup_date_iso":"2014-09-01T18:16:16Z",
      "backup_status":0,
      "backup_result":"",
      "restore_status":0,
      "restore_result":null,
      "created_at_iso":"2014-09-01T18:16:16Z",
      "updated_at_iso":"2014-09-01T18:16:16Z",
      "verify_status":0,
      "verify_result":null,
      "storage_path":"2aad2bb5a70e621ecf251fbd85af6927/backups/3c656a1bcc160769762763c6276c18b9/mysql/test_db_11/2014.09.01.18.16.14",
      "skip_tables":"","backup_size":0
    }
  ],
  "count":2,
  "pagination":
    {
      "previous":null,
      "next":null,
      "current":1,
      "per_page":30,
      "count":2,
      "pages":1
    }
}
```

---

## Create Backup

URL: https://developers.cloud66.com/v3/endpoints/backups/#create
Endpoint: POST /stacks/:stack_id/backups
OAuth scope: admin

Create a new backup task.

**Related models:** Backup

### Parameters

- `stack_id` (string, required) — The stack UID
- `db_type` (string, optional) — Comma separated list of Database types which need backup tasks (valid options: all, mysql, postgresql, redis, mongodb)
- `frequency` (string, optional) — Frequency of backup task in cron schedule format
- `keep_count` (integer, optional) — Number of previous backups to keep
- `gzip` (boolean, optional) — Compress your backups with gzip
- `excluded_tables` (string, optional) — Tables that must be excluded from the backup
- `run_on_replica_server` (boolean, optional) — Run backup task on replica server if available

### Response

```json
{
  "response":
    {
      "ok":true,
      "message":"queued for creation"
    }
}
```

---

## Import Backup

URL: https://developers.cloud66.com/v3/endpoints/backups/#import
Endpoint: POST /stacks/:stack_id/backups
OAuth scope: admin

Import an external backup.

**Related models:** Backup

### Parameters

- `stack_id` (string, required) — The stack UID
- `group` (integer, required) — The group ID of backups that imported backup must restored in
- `db_type` (string, required) — Comma separated list of Database types which need backup tasks (valid options: mysql, postgresql, redis, mongodb)
- `remote_url` (string, required) — A URL to backup file to be imported

### Response

```json
{
  "response":
    {
      "ok":true,
      "message":"Your external backup queued for upload"
    }
}
```
