# How to Create Volumes from Snapshots Snapshots are on-demand disk images of DigitalOcean Droplets and volumes saved to your account. Use them to create new Droplets and volumes with the same contents. You can use any volume snapshot to create new volumes in the same region. ## Create a Volume from a Snapshot using the Control Panel In the control panel’s left menu, click **Backups & Snapshots**, then click the **Snapshots** tab. In the **Snapshots** section, click the **Volumes** tab to view [all volume snapshots in your account](https://cloud.digitalocean.com/images/snapshots/volumes). From there, open the **More** menu of the snapshot you want to use and click **Create Volume** to create a new volume based on it. In the window that opens, you can choose options for the new volume. Choose a preset volume size or enter a custom volume size, either of which must be at least as big as the original volume used to create the snapshot. Next, select a Droplet to attach the volume to. The Droplet must be in a region which supports block storage. Finally, enter a name for the volume, and click **Create Volume** to create a new volume from the snapshot. ## Create a Volume from a Snapshot using Automation To create a new volume from a snapshot, use the following volume creation `doctl` command or API endpoint, and set the `snapshot` field the snapshot’s image ID. ## How to Create a Block Storage Volume Using the DigitalOcean CLI 1. [Install `doctl`](https://docs.digitalocean.com/reference/doctl/how-to/install/index.html.md), the official DigitalOcean CLI. 2. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with `doctl`. 3. Use the token to grant `doctl` access to your DigitalOcean account. ```shell doctl auth init ``` 4. Finally, run `doctl compute volume create`. Basic usage looks like this, but you can [read the usage docs](https://docs.digitalocean.com/reference/doctl/reference/compute/volume/create/index.html.md) for more details: ```shell doctl compute volume create [flags] ``` The following example creates a 4TiB volume named `example-volume` in the `nyc1` region. The command also applies two tags to the volume: ```shell doctl compute volume create example-volume --region nyc1 --size 4TiB --tag frontend,backend ``` ## How to Create a New Block Storage Volume Using the DigitalOcean API 1. [Create a personal access token](https://docs.digitalocean.com/reference/api/create-personal-access-token/index.html.md) and save it for use with the API. 2. Send a POST request to [`https://api.digitalocean.com/v2/volumes`](https://docs.digitalocean.com/reference/api/reference/block-storage/index.html.md#volumes_create). ### cURL Using cURL: ```shell curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ -d '{"size_gigabytes":10, "name": "example", "description": "Block store for examples", "region": "nyc1", "filesystem_type": "ext4", "filesystem_label": "example"}' \ "https://api.digitalocean.com/v2/volumes" ``` ### Go Using [Godo](https://github.com/digitalocean/godo), the official DigitalOcean API client for Go: ```go import ( "context" "os" "github.com/digitalocean/godo" ) func main() { token := os.Getenv("DIGITALOCEAN_TOKEN") client := godo.NewFromToken(token) ctx := context.TODO() createRequest := &VolumeCreateRequest{ Region: "nyc1", Name: "example", Description: "Block store for examples", SizeGigaBytes: 10, } volume, _, err := client.Storage.CreateVolume(ctx, createRequest) } ``` ### Ruby Using [DropletKit](https://github.com/digitalocean/droplet_kit), the official DigitalOcean API client for Ruby: ```ruby require 'droplet_kit' token = ENV['DIGITALOCEAN_TOKEN'] client = DropletKit::Client.new(access_token: token) volume = DropletKit::Volume.new( size_gigabytes: 10, name: 'Example', description: 'Block store for examples', region: 'nyc1' ) client.volumes.create(volume) ``` ### Python Using [PyDo](https://github.com/digitalocean/pydo), the official DigitalOcean API client for Python: ```python import os from pydo import Client client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN")) req = { "size_gigabytes": 10, "name": "ext4-example", "description": "Block store for examples", "region": "nyc1", "filesystem_type": "ext4", "filesystem_label": "ext4_volume_01" } resp = client.volumes.create(body=req) ```