# Backups

##### [Order now](https://puqcloud.com/puqvpncp.php) | [Download](https://download.puqcloud.com/cp/puqvpncp/) | [FAQ](https://faq.puqcloud.com)

## Backups List

**Request Structure:** `https://<puqvpnvp>/api/v1/backups`

**Method:** `GET`

**Cookie: `access_hash=<access_hash>`**

**Example:**

```shell
curl \
-b "access_hash=7effe99173b87e9cdebdab66d6fb23c9b244af250cb09b5dd36d8f80d14a8510b2d00bcba7290252" \
-X GET https://dev.softkeel.com/api/v1/system/backups
```

**Response example:**

```JSON
{
   "error" : "",
   "msg" : {
      "backups" : [
         {
            "backup_name" : "dev.softkeel.com_2023-01-27_19-00-40.zip",
            "creation_date" : "2023-01-27T19:00:57.159356394+01:00",
            "size" : 7.462
         },
         {
            "backup_name" : "dev.softkeel.com_2023-01-27_18-00-39.zip",
            "creation_date" : "2023-01-27T18:00:55.902692143+01:00",
            "size" : 7.462
         },
         {
            "backup_name" : "dev.softkeel.com_2023-01-27_17-00-37.zip",
            "creation_date" : "2023-01-27T17:00:54.501350728+01:00",
            "size" : 7.462
         }
      ]
   },
   "status" : "success"
}
```

**Errors:**

```
-Not authorized
```

- - - - - -

## Backup Create

**Request Structure:** `https://<puqvpnvp>/api/v1/backups`

**Method:** POST

**Cookie: `access_hash=<access_hash>`**

**Options not required:**

```
statistics=0|1
```

**Example:**

```shell
curl \
-b "access_hash=7b8125b94edbb5baf677286fb186942673afe317e0298601990d4cf3dd37991e399e764f9bc2fd20" \
-d "statistics=1" \
-X POST https://dev.softkeel.com/api/v1/backups
```

**Response example:**

```JSON
{
   "error" : "",
   "msg" : {
      "backup_name" : "dev.softkeel.com_2023-01-28_12-50-42.zip",
      "creation_date" : "2023-01-28T12:50:59.772514276+01:00",
      "size" : 7.6038
   },
   "status" : "success"
}
```

**Errors:**

```
-Not authorized
-Error backup creation:
-FTP upload error:
```

- - - - - -

## Backup Restore

**Request Structure:** `https://<puqvpnvp>/api/v1/backups/restore`

**Method:** PUT

**Cookie: `access_hash=<access_hash>`**

**Options required:**

```
backup_name="backup_name"
```

**Example:**

```shell
curl \
-b "access_hash=7b8125b94edbb5baf677286fb186942673afe317e0298601990d4cf3dd37991e399e764f9bc2fd20" \
-d "backup_name=dev.softkeel.com_2023-01-28_12-50-42.zip" \
-X PUT https://dev.softkeel.com/api/v1/backups/restore
```

**Response example:**

```JSON
{
   "error" : "",
   "msg" : "success",
   "status" : "success"
}
```

**Errors:**

```
-Not authorized
-PUQVPNCP status not OK
-There is no backup with this name
-Error backup reader: 
-Empty list of files in file with file list
-Empty archive
-The number of files in the archive does not match the list of files in the file
-Mismatch between files in archive and list of files
-Unable to delete old configuration:
-Failed to open archive, ERROR:
-Failed to create folder:
-Failed to create file:
-Failed to unzip file:
```

- - - - - -

## Backup Download

**Request Structure:** `https://<puqvpnvp>/api/v1/backups/filename`

**Method:** GET

**Cookie: `access_hash=<access_hash>`**

**Example:**

```shell
curl \
-b "access_hash=7b8125b94edbb5baf677286fb186942673afe317e0298601990d4cf3dd37991e399e764f9bc2fd20" \
-X GET https://dev.softkeel.com/api/v1/backups/dev.softkeel.com_2023-01-28_12-00-59.zip \
--output dev.softkeel.com_2023-01-28_12-00-59.zip
```

**Errors:**

```
-Not authorized
```

- - - - - -

## Backups Get Configuration

**Request Structure:** `https://<puqvpnvp>/api/v1/backups/config`

**Method:** GET

**Cookie: `access_hash=<access_hash>`**

**Options required:**

```
backup_name="backup_name"
```

**Example:**

```shell
curl \
-b "access_hash=7b8125b94edbb5baf677286fb186942673afe317e0298601990d4cf3dd37991e399e764f9bc2fd20" \
-X GET https://dev.softkeel.com/api/v1/backups/config
```

**Response example:**

```JSON
{
   "error" : "",
   "msg" : {
      "backup_to_ftp" : true,
      "every_day" : true,
      "every_day_hour" : 13,
      "every_day_minute" : 5,
      "every_day_statistics" : true,
      "every_hour" : true,
      "every_hour_minute" : 50,
      "every_hour_statistics" : true,
      "ftp_password" : "QWEqwe123",
      "ftp_path" : "home/dev.softkeel.com",
      "ftp_server" : "home.uuq.pl",
      "ftp_server_port" : 21,
      "ftp_user" : "puqvpncp",
      "number_backups" : 10
   },
   "status" : "success"
}
```

**Errors:**

```
-Not authorized
```

- - - - - -

## Backups Set Configuration

**Request Structure:** `https://<puqvpnvp>/api/v1/backups/config`

**Method:** PUT

**Cookie: `access_hash=<access_hash>`**

**Options required:**

```
backup_to_ftp=1|0
every_day=1|0
every_day_hour=0-23
every_day_minute=0-59
every_day_statistics=0|1
every_hour=1|0
every_hour_minute=0-59
every_hour_statistics= 1|0
ftp_password=
ftp_path=
ftp_server=
ftp_server_port=
ftp_user=
number_backups= 
```

**Example:**

```shell
curl \
-b "access_hash=7b8125b94edbb5baf677286fb186942673afe317e0298601990d4cf3dd37991e399e764f9bc2fd20" \
-d "backup_to_ftp=1&\
every_day=1&\
every_day_hour=14&\
every_day_minute=45&\
every_day_statistics=1&\
every_hour=1&\
every_hour_minute=40&\
every_hour_statistics=1&\
ftp_password=QWEqwe123&\
ftp_path=home/dev.softkeel.com&\
ftp_server=home.uuq.pl&\
ftp_server_port=21&\
ftp_user=puqvpncp&\
number_backups=100" \
-X PUT https://dev.softkeel.com/api/v1/backups/config

```

**Response example:**

```JSON
{
   "error" : "",
   "msg" : {
      "backup_to_ftp" : true,
      "every_day" : true,
      "every_day_hour" : 14,
      "every_day_minute" : 45,
      "every_day_statistics" : true,
      "every_hour" : true,
      "every_hour_minute" : 40,
      "every_hour_statistics" : true,
      "ftp_password" : "QWEqwe123",
      "ftp_path" : "home/dev.softkeel.com",
      "ftp_server" : "home.uuq.pl",
      "ftp_server_port" : 21,
      "ftp_user" : "puqvpncp",
      "number_backups" : 100
   },
   "status" : "success"
}
```

**Errors:**

```
-Not authorized
-In every hour schedule, the minute parameter must be between 0 and 59
-In the daily schedule, the hour parameter must be between 0 and 23
-In a daily schedule, the minute parameter must be between 0 and 59
-Number backups parameter must be greater than 0
-FTP server must be filled
-FTP user must be filled
-FTP password must be filled
```

##  