Snapshot
Gli Snapshot non sono altro che copie della tuo server virtuale, come i Template mantengono tutti i dati della tua macchina ma hanno le seguenti differenze:
- È possibile ripristinare lo stato di un server a uno Snapshot
- Uno Snapshot non può essere utilizzato per creare una nuova macchina
- Uno Snapshot può essere convertito in un Template ma non vice versa
Snapshot protetti
Gli Snapshot si dividono in Snapshot protetti e non protetti ed hanno le seguenti caratteristiche:
# | Protetti | Non protetti |
---|---|---|
Creazione | Gli Snapshot protetti vengono creati manualmente | Gli Snapshot non protetti vengono creati dai processi periodici |
Conservazione Massima | Gli Snapshot protetti non sono soggetti alla conservazione massima | Gli Snapshot non protetti possono essere cancellati in base alla conservazione massima |
Quantità Massima | Il numero massimo di Snapshot protetti equivale a 12 | Il numero massimo di Snapshot non protetti deriva dalla conservazione massima |
Conversione | Gli Snapshot protetti non possono essere convertiti in non protetti | Gli Snapshot non protetti possono essere convertiti in protetti |
Gestire gli Snapshot
I nostri servizi mettono a disposizione diverse chiamate HTTP per gestire gli Snapshot, di seguito le operazioni più comuni:
Creare uno Snapshot
Per creare uno snapshot è disponibile la seguente richiesta:
Richiesta HTTP
POST /ecs/v2/servers/{servername}/snapshots
{
"description": "my-first-snapshot",
"notes": "my-first-snapshot"
}
Risposta HTTP
{
"status": "ok",
"snapshot": {
"id": 104,
"name": "ec200409-SNP-1",
"user": "admin",
"snapshot_parent": null,
"snapshot_parent_name": null,
"is_last_restored": false,
"protected": true,
"restoring": false,
"source_server": "ec200409",
"status": "CG",
"status_label": "Creating",
"uid": "eb7e9539-3f77-4ebc-811d-58237521a8cc",
"description": "my-first-snapshot",
"notes": "my-first-snapshot",
"active_flag": false,
"size_on_disk": null,
"created_at": "2025-02-07T12:50:02.840Z",
"updated_at": "2025-02-07T12:50:02.840Z",
"deleted_at": null,
"api_version_value": 5,
"api_version": "v5"
},
"action": {
"id": 2115,
"status": "in-progress",
"user": "admin",
"created_at": "2025-02-07T12:50:02.846870+00:00",
"started_at": "2025-02-07T12:50:02.846406+00:00",
"completed_at": null,
"resource": "104",
"resource_type": "SNP",
"type": "create_snapshot",
"progress": 0
}
}
status Code | Messaggio | Spiegazione |
---|---|---|
400 | server in current status can't generate snapshot | Il server non è ancora pronto per generare Snapshot |
400 | can't create a snapshot if there is snapshot pending for selected server | Per creare un nuovo Snapshot è necessario che non esistano Snapshot pendenti |
400 | can't create a snapshot if there is more than 12 protected snapshot for selected server | Non è possibile creare più di 12 Snapshot protetti |
Visualizzare tutti gli Snapshot
Per visualizzare tutti gli Snapshot è disponibile la seguente chiamata:
Richiesta HTTP:
GET /ecs/v2/servers/{servername}/snapshots
Risposta HTTP
{
"status": "ok",
"snapshots": [
{
"id": 104,
"name": "ec200409-SNP-1",
"user": "admin",
"snapshot_parent": null,
"snapshot_parent_name": null,
"is_last_restored": true,
"protected": true,
"restoring": false,
"source_server": "ec200409",
"status": "CD",
"status_label": "Created",
"uid": "eb7e9539-3f77-4ebc-811d-58237521a8cc",
"description": "my-first-snapshot",
"notes": "my-first-snapshot",
"active_flag": true,
"size_on_disk": 3804560,
"created_at": "2025-02-07T12:50:02.840Z",
"updated_at": "2025-02-07T12:52:03.301Z",
"deleted_at": null,
"api_version_value": 5,
"api_version": "v5"
}
]
}
Ottenere uno specifico Snapshot
Per ottenere uno specifico Snapshot è disponibile la seguente richiesta:
Richiesta HTTP
GET /ecs/v2/servers/{servername}/snapshots/{snapshot_id}
Risposta HTTP
{
"status": "ok",
"snapshot": {
"id": 104,
"name": "ec200409-SNP-1",
"user": "admin",
"snapshot_parent": null,
"snapshot_parent_name": null,
"is_last_restored": true,
"protected": true,
"restoring": false,
"source_server": "ec200409",
"status": "CD",
"status_label": "Created",
"uid": "eb7e9539-3f77-4ebc-811d-58237521a8cc",
"description": "my-first-snapshot",
"notes": "my-first-snapshot",
"active_flag": true,
"size_on_disk": 3804560,
"created_at": "2025-02-07T12:50:02.840Z",
"updated_at": "2025-02-07T12:52:03.301Z",
"deleted_at": null,
"api_version_value": 5,
"api_version": "v5"
}
}
Modificare uno Snapshot
Ovviamente è anche possibile modificare alcune informazioni di uno Snapshot:
Richiesta HTTP
PATCH /ecs/v2/servers/{servername}/snapshots/{snapshot_id}
{
"description": "new-snap-description", //update snapshot desc
"notes": "new-snap-notes", //update snapshot notes
"protected": true //protect a server
}
Risposta HTTP
{
"status": "ok",
"snapshot": {
"id": 104,
"name": "ec200409-SNP-1",
"user": "admin",
"snapshot_parent": null,
"snapshot_parent_name": null,
"is_last_restored": true,
"protected": true,
"restoring": false,
"source_server": "ec200409",
"status": "CD",
"status_label": "Created",
"uid": "eb7e9539-3f77-4ebc-811d-58237521a8cc",
"description": "new-snap-description",
"notes": "new-snap-description",
"active_flag": true,
"size_on_disk": 3804560,
"created_at": "2025-02-07T12:50:02.840Z",
"updated_at": "2025-02-07T13:11:20.196Z",
"deleted_at": null,
"api_version_value": 5,
"api_version": "v5"
}
}
status Code | Messaggio | Spiegazione |
---|---|---|
400 | can't convert a protected snapshot to not protected | Impossibile convertire uno Snapshot non protetto in uno protetto |
400 | can't have more then 12 protected snapshot | Non è possibile avere più di 12 Snapshot protetti |
Cancellare uno Snapshot
Infine, ove non sia più necessario, è possibile distruggere uno Snapshot:
Richiesta HTTP
DELETE /ecs/v2/servers/ec200409/snapshots/104
Risposta HTTP
{
"status": "ok",
"snapshot": {
"id": 104,
"name": "ec200409-SNP-1",
"user": "admin",
"snapshot_parent": null,
"snapshot_parent_name": null,
"is_last_restored": true,
"protected": true,
"restoring": false,
"source_server": "ec200409",
"status": "DE",
"status_label": "Deleting",
"uid": "eb7e9539-3f77-4ebc-811d-58237521a8cc",
"description": "new-snap-description",
"notes": "new-snap-description",
"active_flag": false,
"size_on_disk": 3804560,
"created_at": "2025-02-07T12:50:02.840Z",
"updated_at": "2025-02-07T13:12:44.450Z",
"deleted_at": "2025-02-07T13:12:44.447Z",
"api_version_value": 5,
"api_version": "v5"
},
"action": {
"id": 2116,
"status": "in-progress",
"user": "admin",
"created_at": "2025-02-07T13:12:44.442950+00:00",
"started_at": "2025-02-07T13:12:44.440924+00:00",
"completed_at": null,
"resource": "104",
"resource_type": "SNP",
"type": "delete_snapshot",
"progress": 0
}
}
Snapshot Periodici
È anche possibile utilizzare gli snapshot in maniera schedulata per permettere una protezione settimanale del Server.
Per fare ciò è necessario configurare un Cron sul Server interessato.
Attualmente la configurazione disponibile è esclusivamente a cadenza settimanale con i seguenti parametri:
Giorno della settimana (day_of_week) | Massima Conservazione (max_retention) |
---|---|
0 (Domenica) | 2 |
1 (Lunedì) | 4 |
2 (Martedì) | |
3 (Mercoledì) | |
4 (Giovedì) | |
5 (Venerdì) | |
6 (Sabato) |
Info
La Massima conservazione indica il numero massimo di snapshot non protetti consentiti, se la creazione di un nuovo Snapshot dovesse richiedere il superamento di questa cifra verrà preventivamente eliminato lo Snapshot non protetto più vecchio.
Configurare uno Snapshot Periodico
Per configurare uno Snapshot periodico è disponibile la seguente richiesta:
Richiesta HTTP
POST /ecs/v2/servers/{servername}/crons
{
"type": "snapshot_schedule",
"config": {
"typology": "weekly",
"max_retention": 2,
"day_of_week": 0
}
}
Risposta HTTP
{
"status": "ok",
"cron": {
"name": "snapshot_schedule_ec200409",
"schedule": "0 0 * * 0 (m/h/dM/MY/d) UTC",
"enabled": true,
"last_run_at": null,
"infos": {
"max_retention": 2,
"day_of_week": 0
},
"last_run_status": null
}
}
Attenzione
L'attributo schedule può essere rischedulato nel tempo in un arco orario compreso tra le 00:00 e le 06:00 UTC.
Visualizzare la configurazione attiva
Per visualizzare la configurazione attualmente attiva è possibile utilizzare la seguente richiesta:
Richiesta HTTP
GET /ecs/v2/servers/{servername}/crons/snapshot_schedule_{servername}
Risposta HTTP
{
"status": "ok",
"cron": {
"name": "snapshot_schedule_ec200409",
"schedule": "0 0 * * 0 (m/h/dM/MY/d) UTC",
"enabled": true,
"last_run_at": null,
"infos": {
"max_retention": 2,
"day_of_week": 0
},
"last_run_status": null
}
}
Modificare la configurazione attiva
La configurazione attiva può anche essere modificata senza necessitare una nuova richiesta di creazione:
Risposta HTTP
PATCH /ecs/v2/servers/{servername}/crons/snapshot_schedule_{servername}
{
"enabled": true,
"max_retention": 2,
"day_of_week": 6
}
Risposta HTTP
{
"status": "ok",
"cron": {
"name": "snapshot_schedule_ec200409",
"schedule": "0 0 * * 0 (m/h/dM/MY/d) UTC",
"enabled": true,
"last_run_at": null,
"infos": {
"max_retention": 2,
"day_of_week": 0
},
"last_run_status": null
}
}
Cancellare la configurazione
Per cancellare la configurazione e disabilitare gli Snapshot periodici è sufficiente eseguire la seguente richiesta:
Risposta HTTP
DELETE /ecs/v2/servers/{servername}/crons/snapshot_schedule_{servername}
Risposta HTTP
{
"status": "ok",
"cron": {
"name": "snapshot_schedule_ec200409",
"schedule": "0 0 * * 0 (m/h/dM/MY/d) UTC",
"enabled": true,
"last_run_at": null,
"infos": {
"max_retention": 2,
"day_of_week": 0
},
"last_run_status": null
}
}