# Storage mode transitions

When using LABDRIVE to manage and preserve your content, you may have some content that you want to be immediately accesible for your users, while for another content you may want to benefit for a lower storage cost if you do not need to access it frequently. This is usually referred as **hot** or **cold** storage. Check [Storage](broken://pages/-MVZyx3cGE2dYY3YmZKY) for a description of the storage architecture in the platform.

### Storage types and storage classes

Every object preserved in LABDRIVE is assigned to a storage that has a **type** and a **class**. Storage type refers to the provider and geographic location of the underlying storage (AWS in Europe, for instance), while the storage class defines the mode in which the file is, from the range offered by the provider in the region (S3 standard, S3 cold).

Main concepts are:

* **Ingestion storage class:** storage class used to upload content to the platform. LABDRIVE will keep files in this class for a pre-defined period of time (to allow their processing) and then, initiates a transfer process to the Default Storage Class.
* **Default storage class:** storage class that the user wants for the new uploaded content to go.
* **Current storage class:** storage class in which a file is at a given point in time.

####

### Off-line and on-line storage

Storage clases can be **on-line** or **off-line**.&#x20;

* **On-line** (usually **hot** storage) means that your files are immediately accesible. You can open, download or share them.
* **Off-line** (usually **cold** storage) means that your files are NOT immediately accessible. You cannot access (open, download, share, etc) them until you transfer them to an on-line storage class. Transferring them may take some time or have some additional costs.

### Data container default storage

For every container, it is possible to define its storage type and the default class that will be assigned to the content when it is uploaded to the platform:

![](/files/-Mcma5EU_SMCtCUtcXmd)

Every storage type has an ingestion storage class that is used to upload content to. After a period of time defined in the policy, LABDRIVE will change the class for every new file to the indicated default storage class for the selected container.

*For example:* You want for your data to be in Amazon AWS, in Central Europe and using AWS Deep Archive to get low storage costs. &#x20;

In this case, your container's **storage type** is going to be **AWS (eu-central-1)**, and your container is going to have a **default storage class** set to **AWS S3 Deep Archive.**&#x20;

When you upload a file, LABDRIVE is not going to immediately move it to AWS S3 Deep archive (even if it is your default storage class), as reading the file once it is in Deep Archive is expensive and slow and the platform needs to read it in order to generate its hashes, characterize it, etc. LABDRIVE is going to keep it in the ingestion storage class (which is S3 standard), process it and then, migrate it to the default storage class.

### Change the storage class for your content using the management interface

1\. Locate the data container you want to upload to using the **Containers menu** section or by searching.

2\. Select **Check-in** in case you are not checked in the container and you have the check-in/out enabled for the data container.

3\. In the data container page, choose **Explore content**:

![](/files/-MVaQrhG8X-H72fzbynC)

4\. **Select the files or folders you would like to move** to another storage class. If you select a folder, everything that is inside, will also be transferred.

![](/files/-Mcn8SrQDEJ5rZViQAMW)

5\. Select the **Change storage class** function in the Functions side bar:

![](/files/-Mcn8nVZVNkpClb3VOWO)

6\. Confirm that the files LABDRIVE will show you are the files you want to transfer and select **Next**:

![](/files/-Mcn9P23J4uTybZJ3ct6)

7\. Select the desired storage class from the ones you have available for the content and select **next**:

![](/files/-McnAOQSSzv4eGlyloQ4)

8\. Select **"Run action"** to initiate the process.

{% hint style="warning" %}
If you have selected a large amount of files for transfer, you must remain in the same page until the process is completed. If you leave the page, your transfer will be partially completed.
{% endhint %}

{% hint style="danger" %}
If the storage type for your container supports file versioning, every previous version of a file is removed in advance to the storage transition, leaving only the last/most recent one. If you want to preserve any of them, you need to manually retrieve them in advance to any migration.

E.g.: If you have a on-line stored file with three versions (the last one plus two previous modifications) and you transition it to a cold storage, only the most recent version is moved to the cold storage and every previous version is discarded, without being possible to recover them.
{% endhint %}

### Change the storage class for your content using the API

{% hint style="info" %}
API examples here are just illustrative. Check the [LABDRIVE API documentation](/labdrive/developers-guide/api-extended-documentation.md) for additional information and all available methods.
{% endhint %}

1\. Sign in to the LABDRIVE Management Interface

2\. Obtain your LABDRIVE API key by selecting your name and then **Access Methods:**

![](/files/-MVaJWnwSfyMMFbO42X1)

and then:

#### Get the available storage types and classes

To get the storage **TYPES** available, use:

```
curl --request GET \
    --url "$your_labdrive_url/api/storages" \
    --header "Content-Type: application/json" \
    --header "authorization: Bearer $your_labdrive_api_key" \
    --data ''
```

![](/files/-MeUovE6xaLJAomQ_m9n)

and then, as every storage type has storage **CLASSES**, you can get them this way:

![](/files/-MeUolCvqCr_TxbrqEVe)

```
curl --request GET \
  --url  "$your_labdrive_url/api/storage/{your storage type id}/classes" \
  --header "Content-Type: application/json" \
  --header "authorization: Bearer $your_labdrive_api_key" \
  --data ''
```

![](/files/-MeUpJdQ3DEQbaToq9n9)

#### Get the storage class in which a file is

```
curl --request GET  --url "$your_labdrive_url/api/file/{your_file_id}" \
     --header "Content-Type: application/json" \
     --header "authorization: Bearer $your_labdrive_api_key" \
     --data '{}'
```

Where,&#x20;

* **{your file id}** is the id of the file that you are querying for.&#x20;

And them, look for the **storage\_class** section:

![](/files/-McnYZQHsmcl_gBMOpAz)

####

#### Get the scheduled or running storage class transfer processes

```
curl --request GET  --url "$your_labdrive_url/api/container/{your_container_id}/storage_class/migrations" \
     --header "Content-Type: application/json" \
     --header "authorization: Bearer $your_labdrive_api_key" \
     --data '{
            "conditions" : [
                {
                    "status" : "{status}"
                }
            ]
        }'
```

Where,&#x20;

* **{your container id}** is the id of the container in which your files are.
* **{status}** is the status you are interested in, and must be,&#x20;

  * PENDING: Scheduled to be executed or waiting for available resources.
  * RUNNING: Transfer process has being initiated.
  * SUCCESS: Transfer completed successfully.
  * ERROR: Transfer completed unsuccessfully.

####

#### Request a transfer from one storage class to another for a file

Execute the following method:

```
curl --request POST  --url "$your_labdrive_url/api/container/{your_container_id}/files/storage_class" \
     --header "Content-Type: application/json" \
     --header "authorization: Bearer $your_labdrive_api_key" \
     --data '{
            "files_id": [{id_of_the_file/s_to_transfer}],
            "storage_class_id": {destination_class_id}
     }'
```

Where,&#x20;

* **{your container id}** is the id of the container in which your files are.
* **{id of the file to transfer}** is the id of the file to apply the transfer process to. You can include up to 1.000 file ids in the same request, separated by commas.&#x20;
  * All files must belong to the same container indicated in the previous parameter.
  * **If you request to change the class for a folder, the migration for every file inside it is also requested automatically by LABDRIVE.**
* **{destination class id}** is the id of the destination storage class.

![](/files/-McnUWGDcP2Ilkf9IlNf)

{% hint style="danger" %}
If the storage type for your container supports file versioning, every previous version of a file is removed in advance to the storage transition, leaving only the last/most recent one. If you want to preserve any of them, you need to manually retrieve them in advance to any migration.

E.g.: If you have a on-line stored file with three versions (the last one plus two previous modifications) and you transition it to a cold storage, only the most recent version is moved to the cold storage and every previous version is discarded, without being possible to recover them.
{% endhint %}


---

# 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://docs.libnova.com/labdrive/get-started/storage-mode-transitions.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.
