Recently we’ve introduced the ability to export Compute instance snapshots, which can in turn be either downloaded locally as an additional backup measure or used to create custom templates. In this post we will give you a quick overview of how to do it using the exo CLI.

Creating a Snapshot

You can create a snapshot either from the Exoscale portal or using the exo CLI:

$ exo compute instance list
│                  ID                  │    NAME     │   ZONE   │      TYPE       │   IP ADDRESS   │  STATE  │
│ ec572155-8c31-4c68-afa1-c1f04fa3cd80 │ my-instance │ ch-gva-2 │ standard.medium │ │ running │

$ exo compute instance snapshot create my-instance
Creating snapshot of "my-instance"... success
│   SNAPSHOT    │                                         │
│ ID            │ 27034cc8-d972-49a6-bc87-e104dae95f83    │
│ Name          │ my-instance_ROOT-3825399_20220614143058 │
│ Creation Date │ 2022-06-14 14:30:58 +0000 UTC           │
│ State         │ exported                                │
│ Size (GB)     │ 50                                      │
│ Instance      │ my-instance                             │
│ Zone          │ ch-gva-2                                │

Exporting a Snapshot

Once the snapshot is created it can also be exported. The export process will create a link that can be used to download the snapshot file:

$ exo compute instance snapshot export 27034cc8-d972-49a6-bc87-e104dae95f83
Exporting snapshot 27034cc8-d972-49a6-bc87-e104dae95f83... 3s
│ URL      │ │
│ Checksum │ 0f1f74d9d4cef1d8e578b5854b4f99ad                  │

Depending of the disk size, the export process can take quite some time, so please be patient. Once you have the URL you can download the snapshot. Note that the URL returned by this operation is only valid for 6 hours: passed this time, you will have to export the snapshot again the retrieve a fresh URL (subsequent export operations are virtually instantaneous).

Please take note of the URL and checksum. You will use them at a later stage.

Registering a Snapshot as a Template

Before moving on to the template registration part, we need to look up the boot mode of the Compute instance template the snapshot originates from, as we’ll need to specify it during registration to ensure the Compute instances that will use it can boot properly.

If you are using Linux and Bash you can use the following script to get the boot mode:

INSTANCE_NAME=$(exo compute instance snapshot show ${SNAPSHOT_ID} --output-template '{{ .Instance }}')
TEMPLATE_NAME=$(exo compute instance show "${INSTANCE_NAME}" --output-template '{{ .Template }}')
BOOTMODE=$(exo compute template show "${TEMPLATE_NAME}" --output-template '{{ .BootMode }}')

Or in Powershell:


$command = {exo.exe compute instance snapshot show "$SNAPSHOT_ID" --output-template '{{ .Instance }}'}
$INSTANCE_NAME = Invoke-Command -ScriptBlock $command

$command = {exo.exe compute instance show "${INSTANCE_NAME}" --output-template '{{ .Template }}'}
$TEMPLATE_NAME = Invoke-Command -ScriptBlock $command

$command = {exo.exe compute template show "${TEMPLATE_NAME}" --output-template '{{ .BootMode }}'}
$BOOTMODE = Invoke-command -ScriptBlock $command

This will store the boot mode in the $BOOTMODE variable which we will use later.

Now that you have the details of the exported snapshot you can either download it, or use it to register a custom template on Exoscale to reuse it as a basis for new Compute instances deployments.

To register it as a custom template you simply pass the URL and checksum above to the exo compute template register command:

$ exo compute instance-template register NAME URL CHECKSUM [flags]
    --boot-mode $BOOTMODE \
    --username ubuntu \
    --zone ch-gva-2 \
    --description "My test template"
Registering the template............................................. success
│   TEMPLATE    │                                      │
│ ID            │ 06b97217-3820-4fcc-91af-f51aff68823c │
│ Name          │ my-test-template                     │
│ OS Type       │ Other (64-bit)                       │
│ Creation Date │ 2020-05-13T10:37:48Z                 │
│ Zone          │ ch-gva-2                             │
│ Disk Size     │ 10 GiB                               │
│ Username      │ ubuntu                               │
│ Password?     │ true                                 │

Alternatively, the exo compute template register "New Template" --from-snapshot <ID of a snapshot> command performs the snapshot export operation and then registers the template using the exported snapshot file URL/checksum directly.

Finally, you can of course start an instance from the template:

$ exo compute instance create test --template 06b97217-3820-4fcc-91af-f51aff68823c
Creating private SSH key
Deploying "test" ⠙                                                                                done

That’s it! You can now use a single Exoscale instance as a golden master for your other instances.