View a markdown version of this page

Utilizzare CreateSnapshot con una CLI - Amazon Elastic Compute Cloud

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Utilizzare CreateSnapshot con una CLI

I seguenti esempi di codice mostrano come usareCreateSnapshot.

Gli esempi di operazioni sono estratti di codice da programmi più grandi e devono essere eseguiti nel contesto. È possibile visualizzare questa operazione nel contesto nel seguente esempio di codice:

CLI
AWS CLI

Come creare uno snapshot

Questo comando di esempio crea uno snapshot del volume con l’ID volume vol-1234567890abcdef0 e una breve descrizione per identificare lo snapshot.

Comando:

aws ec2 create-snapshot --volume-id vol-1234567890abcdef0 --description "This is my root volume snapshot"

Output:

{ "Description": "This is my root volume snapshot", "Tags": [], "Encrypted": false, "VolumeId": "vol-1234567890abcdef0", "State": "pending", "VolumeSize": 8, "StartTime": "2018-02-28T21:06:01.000Z", "Progress": "", "OwnerId": "012345678910", "SnapshotId": "snap-066877671789bd71b" }

Come creare uno snapshot con tag

Questo comando di esempio crea uno snapshot e applica due tag, ovvero purpose=prod e costcenter=123.

Comando:

aws ec2 create-snapshot --volume-id vol-1234567890abcdef0 --description 'Prod backup' --tag-specifications 'ResourceType=snapshot,Tags=[{Key=purpose,Value=prod},{Key=costcenter,Value=123}]'

Output:

{ "Description": "Prod backup", "Tags": [ { "Value": "prod", "Key": "purpose" }, { "Value": "123", "Key": "costcenter" } ], "Encrypted": false, "VolumeId": "vol-1234567890abcdef0", "State": "pending", "VolumeSize": 8, "StartTime": "2018-02-28T21:06:06.000Z", "Progress": "", "OwnerId": "012345678910", "SnapshotId": "snap-09ed24a70bc19bbe4" }
PowerShell
Strumenti per PowerShell V4

Esempio 1: questo esempio crea uno snapshot del volume specificato.

New-EC2Snapshot -VolumeId vol-12345678 -Description "This is a test"

Output:

DataEncryptionKeyId : Description : This is a test Encrypted : False KmsKeyId : OwnerAlias : OwnerId : 123456789012 Progress : SnapshotId : snap-12345678 StartTime : 12/22/2015 1:28:42 AM State : pending StateMessage : Tags : {} VolumeId : vol-12345678 VolumeSize : 20
  • Per i dettagli sull'API, vedere CreateSnapshot in AWS Strumenti per PowerShell Cmdlet Reference (V4).

Strumenti per V5 PowerShell

Esempio 1: questo esempio crea uno snapshot del volume specificato.

New-EC2Snapshot -VolumeId vol-12345678 -Description "This is a test"

Output:

DataEncryptionKeyId : Description : This is a test Encrypted : False KmsKeyId : OwnerAlias : OwnerId : 123456789012 Progress : SnapshotId : snap-12345678 StartTime : 12/22/2015 1:28:42 AM State : pending StateMessage : Tags : {} VolumeId : vol-12345678 VolumeSize : 20
  • Per i dettagli sull'API, vedere CreateSnapshot in AWS Strumenti per PowerShell Cmdlet Reference (V5).

Per un elenco completo delle guide per sviluppatori AWS SDK e degli esempi di codice, consulta. Crea EC2 risorse Amazon utilizzando un AWS SDK Questo argomento include anche informazioni su come iniziare e dettagli sulle versioni precedenti dell’SDK.