In order to maintain backups of disk images without having to pay DigitalOcean for them monthly, it would be useful to be able to download them and then later upload any that need to be used again.
At the present time, downloading does not seem to be possible; the only instructions I have found so far not only don't work, but couldn't even work in theory as I understand it -- in that they use sshfs to mount the volume's filesystem locally, then try to use dd (a volume-copying tool) to do the copying.
Tentatively, uploading/restore is fully supported, although this is still limited to images that are based on a Linux-like filesystem.
I got an error with the command they suggested, and modified it to this:
root@statler:/mnt# sudo sshfs -o allow_other email@example.com:/ /mnt/droplet
...but then this didn't work:
dd if=/mnt/droplet of=tootcat2.hypertwins.net-1523357095826-abandoned dd: error reading '/mnt/droplet': Is a directory
Tentatively, this seems to be the way to go, for an image that's running as a virtual machine.
1. Find the device name for the root filesystem:
Filesystem 1K-blocks Used Available Use% Mounted on udev 1530884 0 1530884 0% /dev tmpfs 308032 31616 276416 11% /run /dev/vda1 50758760 12572412 38169964 25% / tmpfs 1540156 4 1540152 1% /dev/shm tmpfs 5120 0 5120 0% /run/lock tmpfs 1540156 0 1540156 0% /sys/fs/cgroup /dev/sda 51475068 30045492 18791752 62% /mnt/cloud4-01 tmpfs 308032 0 308032 0% /run/user/0
This tells me that my main partition is
/dev/vda1 and that I need 50,758,760 kb (50 GB) of space to store the image. Presumably, then, the entire (bootable) drive is at
2. cd to a local drive with enough room.
3. Download the image:
- Model: ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz
- Live example:
ssh firstname.lastname@example.org "dd if=/dev/vda | gzip -1 -" | dd of=cloud4.live.gz
This takes a long time, so you may want to check up on the size of the output file (in this case, cloud4.live.gz) to see how it's progressing.
Also, copying an image while the disk is in use (which seems to be unavoidable with Digital Ocean) may cause inconsistencies in the resulting image, so running fsck on it afterwards, and then manually spot-checking the contents for sanity, is probably a good idea.
(Currently waiting for my own image to download; will then be able to see if this worked.)
Possibly the "custom images" feature is the way to go?