Download and Backup Digital Ocean Snapshot Images
NOTE!: I haven’t had time to test going back and restoring. I am hesitant to remove my images from DigitalOcean until I can confirm the backup is working properly. I’ve been holding back on posting this until then, but I’m tired of sitting on this and hope it helps others.
I am not responsible for any data loss or harm you or another may cause to your system or data.
Add an SSH Key to your account
Use PuttyGen to generate a key, save the public and private
Add the key to DO
Create New Droplet
Create a droplet from the snapshot image you want to download
Remember to check the key you created
You may need to choose a larger storage space if you’re going to create a backup locally.
Validate Previous SSH Settings
If you disabled logging in from root, you’ll need to reset the root password from the DO pannel.
Then log in with the DO console and edit the
Enable PermitRootLogin yes
Then add this line below
Make sure if you’re white-listing users you either add root or comment the line out
#AllowUsers UserName root
Restart the SSH server with
service ssh restart
Now if you’ve added your SSH key to Digital Ocean and the droplet when you created it you should be able to connect with Putty.
Connecting with Putty
Add IP, Connection > Data > Auto Login Username: root
Add your private key, Connection > SSH > Auth > Private Key File > Browse
Connect, enter your passphrase you created when you generated the SSH Key
You should see something like:
Authenticated with public key "Digitatl-Ocean-rsa-key-#######"
Passphrase for key "Digital-Ocean-rsa-key-#######:"
Optional (Recommended) – Create Serverside Backup
You can choose to zip everything up on the server if you’d like or just copy it all over in the next step
https://help.ubuntu.com/community/DriveImaging You can use the BZ compression if you want, I chose gzip.
at the root with root permissions run
dd if=/dev/vda1 | gzip > backup.gz
vda1 can be found via:
ls /dev/disk/by-label/ -l
You can watch the progress with another terminal and the following command; remove the h if you want to watch the bytes
watch -n 3 “du -h backup.gz”
Exclude or include only specific files:
exclude from file:
What to include?
This askubuntu has a good answer
/var (except /var/run, /var/cache, /var/tmp)
/usr (/usr/local only, nothing else)
You can also install NCDU
and determine which folders are your big hitters for a better idea
Just configs no executables
Time To Backup
Lets build a big scary backup command!
dpkg --get-selections > app-list.txt
tar -cvpjf /backups/backup-$(date +%Y-%m-%d-%H-%M-%S).tar.bz2 --one-file-system / -X my-excludes.txt -T my-includes.txt --hard-dereference
Copy file from server
Take a deep breath and pull the trigger…
Remove those snapshots from Digital Ocean… Phew