An Introduction to DigitalOcean Snapshots
Snapshots provide a full copy of a DigitalOcean Droplet, saving everything from a Droplet’s disk to a disk image within your DigitalOcean account. Once created, a Snapshot can be used to create new Droplets with the same contents of the Snapshot, restore the source Droplet to the point in time when the Snapshot was taken, or transfer a copy to different regions.
When Should I Use Snapshots?
Snapshots are a great way to save the entire contents of a Droplet which can then later be used to create a new, matching Droplet, or restore the existing Droplet to the time when the Snapshot was taken. They're helpful when you reach a milestone in your project and don't want to wait for the weekly backup to run, when you want to share a copy of the Droplet with other users or teams, or when you want to create a template from a Droplet to use in another region.
Snapshots can also be used to save the contents of Block Storage Volumes, although Snapshots of Block Storage Volumes cannot be moved between regions or transferred to a different DigitalOcean account.
Note: If you create a Snapshot of a Droplet, it will not include a Snapshot of any additional Block Storage Volumes attached to the Droplet. However, you can create Snapshots of Block Storage Volumes separately.
DigitalOcean Snapshots at a Glance
- Pricing: Snapshots are charged at a rate of $0.05/GB per month. Pricing is based on the size of the snapshot, not the size of the filesystem being saved.
- Retention: Snapshots are retained indefinitely until manually deleted.
- Availability: Snapshots are available for any Droplet or Block Storage Volume, across all regions.
Creating a Snapshot from an Existing Droplet
Snapshots can be created from an existing Droplet in order to save all contents from the Droplet’s disk. Depending on the services running on the Droplet, you may want to power off the Droplet before taking a Snapshot in order to ensure all applications have written out data to disk. For example, many databases don’t guarantee data consistency on disk unless the database service is stopped or the entire Droplet is powered off.
Option 1: Power Off the Droplet (Preferred)
Powering off a Droplet can be done either through the DigitalOcean Control Panel, or by using ssh to connect to the server and running the
shutdown commands. Using ssh is the preferred method as it will ensure all services are stopped before the shutdown occurs, however we’ll cover both methods below.
To power off a Droplet from the command line, use ssh to connect to the Droplet.
- ssh user@your_server_ip
Once you're connect, issue the
- sudo shutdown -h now
To power off a Droplet through the Control Panel, click the Droplet name from the list of Droplets, and click on the ON switch in the upper-right corner, then click ‘Turn off’ from the pop-up warning window (You may not see a warning if you have previously disabled it).
Once the Droplet is powered off, you can take a Snapshot knowing that all data has been written out to the Droplet’s disk, and therefore will be saved in the Snapshot.
To take a Snapshot, first navigate to the Droplet within the DigitalOcean Control Panel, then click the Snapshots link from the left menu. From the Snapshot screen, enter a name for the Snapshot, or accept the default, and then click the Take Snapshot button to create a Snapshot.
A progress bar will show the progress of Snapshot creation, and once complete, the Snapshot will be listed along with any other previous Snapshots.
Option 2: Take a Live Snapshot
Alternatively, you can take a live Snapshot without powering off your Droplet. To do so, navigate to the Droplet in the DigitalOcean Control Panel, and then click Snapshots from the left menu. From the Take snapshot screen, enter a Snapshot name if desired, or keep the default, and then click the Take Live Snapshot button to create a Snapshot.
As with a Snapshot taken if the Droplet were powered off, a progress bar will show you the status of the Snapshot, and it will appear in the Droplet’s Snapshot list once complete.
Making a Snapshot Available within Different Regions
Once a Snapshot is created, it is initially available only in the region where it was created. If you want to use the Snapshot to create Droplets in other regions, then you’ll first need to make the Snapshot available in those regions. To do so, first navigate to the Snapshots section for the Droplet you want to copy to other regions. From there, click on the More menu, and select Add to region from the dropdown menu. This will display a list of all available regions. Cick on any region name to make the Snapshot available in that region.
After copying a Snapshot to another region, it can be used to create new Droplets in that region. For detailed information on migrating Droplets between regions, see the article How to Migrate DigitalOcean Droplets Using Snapshots.
Creating a new Droplet from a Snapshot
Any Snapshot created from a Droplet can be used to create new Droplets in any region where the Snapshot is available. To create a Droplet from a Snapshot, click the Create menu and select Droplets. From the Create Droplets page, select Snapshots under the Choose an image header, and then choose the Snapshot you would like to create a Droplet from.
Note: When creating a new Droplet from a Snapshot, you must select a disk size equal to or larger than the Droplet that was used to create the Snapshot.
Continue Droplet creation by selecting the Droplet size, region, and any additional options. Finally, click Create to create a Droplet based on the selected Snapshot.
Restoring a Droplet from a Snapshot
Snapshots can also be used to restore a Droplet to the point in time the Snapshot was taken. This can be useful for restoring files that were accidentally deleted or to revert to a known-good Droplet to recover from accidental configuration changes.
To restore a Droplet from a previous Snapshot, click Images from the top menu of the DigitalOcean Control Panel. From there, you will be presented with a list of all Snapshots available in your account. Locate the Snapshot you want to restore a Droplet from and click the More menu next to the Snapshot, then select Restore Droplet. A Restore Droplet window will confirm that the existing Droplet will be replaced with the older Snapshot image. Click Restore Droplet to continue, and the Droplet will be restored from the selected Snapshot.
Creating a Snapshot from a Block Storage Volume
Snapshots can also be used with Block Storage Volumes. Once created, a Snapshot of a Block Storage Volume can be used to create a new Volume. By default the data on Volumes and their Snapshots is encrypted at rest.
The same general guidelines apply for creating Snapshots of Volumes as apply with Snapshots of Droplets: if there are applications that are actively writing to the Volume, the Droplet attached to the Volume should be powered off before taking a Snapshot in order to ensure data consistency.
To create a Snapshot of a Block Storage Volume, first navigate to the list of Volumes by clicking Droplets then clicking Volumes from the sub-navigation menu, as shown in the following image.
Click the More menu for the Volume you wish to create a Snapshot of, and then select Take Snapshot. You will be presented with a window allowing you to change the name of the Snapshot. Enter the name you’d like to use, or accept the default, and then click Take Snapshot to create a new Snapshot.
Creating a Block Storage Volume from a Snapshot
You can view a list of all Volume Snapshots for your account by navigating to Images, selecting Snapshots from the secondary navigation menu, and then selecting Volumes under the Snapshots section.
From there, select any Volume Snapshot, click the More menu, and select Create Volume to create a new Volume. You will then be presented with a window with options for creating a new Volume from the Snapshot, as shown in the image below.
From there, choose a Volume size, or enter a custom Volume size. The Volume size chosen must be equal to or greater than the size of the original Volume used to create the Snapshot. Next, select a Droplet to attach the Volume to (which must be in a region which supports Block Storage), enter a name for the Volume, and click on Create Volume to create a new Volume from the Snapshot.
Removing a Snapshot
Snapshots will remain in your account until they are manually removed. To remove a Snapshot from your account, navigate to the Snapshot list by clicking Images, then click Snapshots in the secondary navigation menu. Snapshots are separated into two lists: one for Droplet Snapshots and one for Volume Snapshots. To remove a Snapshot, click the More menu, and then click Delete. A confirmation window will appear; from there, click Delete Snapshot to remove the Snapshot.
In this article, we introduced DigitalOcean Snapshots and provided basic instructions for creating Snapshots for Droplets and Block Storage Volumes. Snapshots provide an easy way to archive a Droplet or Volume at a point in time and can later be used to create new Droplets or Volumes. For more advanced usage of Snapshots, see the following articles: