# Back-ups

## Overview of all back-ups

<mark style="color:blue;">`GET`</mark> `https://cronly.app/api/backups`

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer: `API token` |

{% tabs %}
{% tab title="200 All of your backups" %}

```json
[
    {
        "id": 1,
        "username": "username_on_server",
        "company_id": 1,
        "server_id": 1,
        "deleted_at": null,
        "created_at": "2024-03-04T18:19:56.000000Z",
        "updated_at": "2024-03-04T18:19:56.000000Z"
    }
]
```

{% endtab %}
{% endtabs %}

## Details of back-up

<mark style="color:blue;">`GET`</mark> `https://cronly.app/api/backups/{server_id}/{username}`

#### Query Parameters

| Name                                         | Type   | Description                                               |
| -------------------------------------------- | ------ | --------------------------------------------------------- |
| server\_id<mark style="color:red;">\*</mark> | String | The identifier of the server you want to view             |
| username                                     | String | The username on the server whose back-up you want to view |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer: `API token` |

{% tabs %}
{% tab title="200 The back-up" %}

```json
{
    "id": 1,
    "username": "username",
    "company_id": 1,
    "server_id": "server_identifier",
    "deleted_at": null,
    "created_at": "2024-03-04T18:19:56.000000Z",
    "updated_at": "2024-03-04T18:19:56.000000Z"
}
```

{% endtab %}

{% tab title="404: Not Found The back-up was not found" %}

```json
{
    "error": "Back-up not found"
}
```

{% endtab %}
{% endtabs %}

## Create a new back-up

<mark style="color:green;">`POST`</mark> `https://cronly.app/api/backups`

The source of this request must match the IP Address configured in the corresponding Server. This will either create an entire new back-up if there is no server with a matching username, or it will create a new snapshot of the back-up.

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer: `API token` |

#### Request Body

<table><thead><tr><th>Name</th><th width="235">Type</th><th>Description</th></tr></thead><tbody><tr><td>username<mark style="color:red;">*</mark></td><td>String</td><td>The username on the server whose back-up you want to view</td></tr><tr><td>server_id<mark style="color:red;">*</mark></td><td>String</td><td>The identifier of the server you want to view</td></tr><tr><td>file_content</td><td>String</td><td>The content of the crontab file</td></tr></tbody></table>

{% tabs %}
{% tab title="200 The newly created back-up" %}

```json
{
    "id": 1,
    "username": "username_on_server",
    "company_id": 1,
    "server_id": "server_identifier",
    "deleted_at": null,
    "created_at": "2024-03-04T18:19:56.000000Z",
    "updated_at": "2024-03-04T18:19:56.000000Z"
}
```

{% endtab %}
{% endtabs %}

## Delete a back-up

<mark style="color:red;">`DELETE`</mark> `https://cronly.app/api/backups/{server_id}/{username}`

#### Query Parameters

| Name                                         | Type   | Description                                                   |
| -------------------------------------------- | ------ | ------------------------------------------------------------- |
| server\_id<mark style="color:red;">\*</mark> | String | The identifier of the server whose back-up you want to delete |
| username                                     | String | The Username whose back-up you want to delete                 |

#### Headers

| Name                                            | Type   | Description         |
| ----------------------------------------------- | ------ | ------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | Bearer: `API token` |

{% tabs %}
{% tab title="204: No Content The back-up has been deleted successfully" %}

```json
{
    "success": "Back-up deleted"
}
```

{% endtab %}

{% tab title="404: Not Found The back-up was not found" %}

```json
{
    "error": "Back-up not found"
}
```

{% endtab %}
{% endtabs %}

##
