Skip to content

Instantly share code, notes, and snippets.

@amochkin
Last active January 31, 2024 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amochkin/98b39567f63fd5222858e84c8d41d2a4 to your computer and use it in GitHub Desktop.
Save amochkin/98b39567f63fd5222858e84c8d41d2a4 to your computer and use it in GitHub Desktop.
Download droplet snapshot or backup from Digital Ocean

Download droplet snapshot or backup from Digital Ocean

Problem

Digital Ocean does not allow you to download backups or shanpshots of the droplet. This may be a problem if you want to migrate from Digital Ocean to somewhere else.

Solution

  1. Boot into Recovery Console (choose Boot from Recovery ISO option) for the source droplet. If you need specific backup or snapshot, you would need to restore it either into source droplet or create a new droplet out of it.
  2. Login to the Recovery Console. You would need to choose Interactive Shell mode. Figure out what drives you need to backup (using lsblk for example). Usually it is /dev/vda.
  3. Dump the drive to an image using SSH. It should accept your SSH keys allright. Launch this command:
ssh -o UserKnownHostsFile=/dev/null root@<droplet-external-ip> "dd if=<drive-to-backup> | gzip -1 -" | dd of=<image-name>.gz status=progress
# Example: 
# ssh -o UserKnownHostsFile=/dev/null root@162.36.52.210 "dd if=/dev/vda | gzip -1 -" | dd of=image.gz status=progress

Note: -o UserKnownHostsFile=/dev/null is used to mitigate SSH keys strict check protection error. You can omit it if you've never connected to that host prior.

Next steps

To restore the backup, you would need to decompress is using gzip, like so gzip -d image.gz. And then dd it onto your target drive, like so dd if=image of=/dev/sda. You will get the original partition setup, which might mismatch your target drive geometry, but it is OK as long as your target drive is bigger than image size. But thats another story, look for partition resize solution.

@amochkin
Copy link
Author

For Vultr the procedure would be slightly different:

  1. Go to VM Settings -> Custom ISO. Choose SystemRescue CD. The VM will automatically reboot.
  2. Login to Console. You will need to reset root password with passwd command. Then modify iptables rules: iptables -F INPUT && iptables -A INPUT -j ACCEPT. Then check the drive path, same way as for Digital Ocean using lsblk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment