How is your backup strategy? You can protect your cloud assets from disaster by taking regular backups. Here’s how to use DigitalOcean’s two imaging systems, backups and snapshots.
What is the difference?
Backups and snapshots both produce a full disk image of your droplet at any given time. You can restore the state of the drop with the help of the picture. With DigitalOcean you can also spin a new drop with the backup or snapshot image as the base.
The difference is in how the image is created. “Backups”
Backups add another 20% to the monthly cost of your drop. They’re stored in the same data center as your drop, so it’s plausible – while perhaps unlikely – that a data center-wide outage or natural disaster could keep you from using your backups.
Snapshots are images on demand. You create them manually using the control panel or the API. Once created, snapshots remain in your account indefinitely until you explicitly delete them.
Snapshots are billed based on their size. You pay $ 0.05 / GiB per month. Snapshots are taken in the same data center as your droplet. You can make snapshots available by snapshot in other data center regions.
Unlike backups, snapshots are not limited to drops. You can also take snapshots of your block storage volumes. Consider taking snapshots of your volumes regularly as they are not included in droplet snapshots or backups.
Set up droplet backups
First, let’s take a look at setting up automatic droplet backups.
Log in to your digital control panel. Click on a drop on the home page. Then, on the droplet’s detail page, click the “Backups” link in the sidebar. You will see a button “Enable backups”. Click the button to activate backups.
DigitalOcean automatically assigns you a weekly backup window that you cannot change or modify. On the page you will see what your backup plan is; until your schedule has run, no backups are available for your drop.
You can automate backup setup with Doctl, DigitalOcean’s command line client. Once verified, run
doctl compute droplet list to get the list of drops in your account. Write down the ID of the droplet you want to configure.
Then set up backups for the drop:
doctl compute droplet-action enable-backups
After backups have been made, you can view them with another command:
doctl compute droplet backups
Restore a backup
You can view your four saved backups at the bottom of the Backups page of a droplet. Click the “More” button to view the available options.
You can restore your drop by clicking on “Restore Droplet” and confirming the confirmation question. This will overwrite your current droplet with the contents of the backup.
The option “Create Droplet” offers you a different recovery strategy. This allows you to configure a new droplet with the backup as the first image. You will be taken to the drop creation page to choose the hardware plan for your new drop.
Finally, you can convert backups into snapshots. This allows you to back up indefinitely, after the end of the standard monthly retention period. You can also use snapshots to transfer backup data to a new data center region.
To manage snapshots in the web interface, select a droplet and click the “Snapshots” link in the sidebar.
You take new snapshots using the controls at the top of the page. Give the snapshot a name and click “Take live snapshot”. This catches the drop without turning it off. To ensure data consistency, close the drop before taking the snapshot.
Snapshots take up to 1 minute per GB of data used by your drop. The snapshot will be listed under “Droplet Snapshots” when the process is complete.
To take a snapshot of a volume, click the Volumes link in the left sidebar. Click the “More” button next to one of your volumes. Press “Take Snapshot” and give your snapshot a name. Volume snapshots require a similar creation time to droplet snapshots.
You can access all your snapshots of droplets and volumes from the “Images” link in the sidebar. Use the “Drops” and “Volumes” tabs to view your snapshots.
Using the “More” menu, you can create a droplet from the snapshot, restore the droplet (or volume) using the snapshot, or transfer the snapshot to another area. The latter option then allows you to create a new droplet in another data center that uses the snapshot as the base image.
You can orchestrate snapshot actions with Doctl. Here are some helpful commands when working with snapshots:
# Get all snapshots stored for a droplet doctl compute droplet snapshots
# Create a snapshot of a droplet doctl compute droplet-action snapshot # Create a snapshot of a volume doctl compute volume snapshot # List all snapshots in your account doctl compute snapshot list # Delete a snapshot doctl compute snapshot delete
compute droplet list
compute volume list and
compute snapshot list commands to get the resource IDs to be supplied to the snapshot commands listed above.
Back up other DigitalOcean resources
Backups are for drops only; Snapshots are for drops and volumes. You cannot use them with any other DigitalOcean source type.
You should consider how to back up your other DigitalOcean data. The platform’s managed services – such as Managed Databases and Spaces object storage – have integrated backups within DigitalOcean’s infrastructure. You may want to manually back up to another cloud provider to ensure redundancy.
DigitalOcean backups are a set-it-and-forget-it approach to backups that “should just work” for most light workloads. However, the weekly schedule and storage in the same data center will not work for business-critical matters. If so, you should consider periodic snapshots or a custom backup system.
Snapshots are ideal when you are about to make a major change to the droplet configuration. You can take a snapshot of your machine to give you a recovery option in the event of a failure. Snapshot portability allows you to move data between DigitalOcean regions without having to manually transfer anything.