Is there a way to restore a droplet from another droplet's snapshot (different disk sizes)?

January 15, 2019 466 views
Development DigitalOcean Ubuntu

Basically I have droplet A which hosts a wordpress site, and droplet B which was once upon a time a development server for droplet A, but which has fallen into disrepair. I’d like to start fresh and convert droplet B into a copy of droplet A, but when I create a snapshot of droplet A and try to select it from the restore menu of droplet B it doesn’t show up. I suspect this may be because droplet A has 8GB memory and 40GB disk, whereas droplet B has 1GB memory and 30GB disk, but enlighten me if I am wrong.

Is there a (free) way to accomplish what I am after?

1 Answer

Hey friend,

Great question. I’m afraid there isn’t a way to deploy a snapshot onto a smaller (disk) droplet at this time. The partitioning is all part of the snapshot and we do not currently have any logic to override it.

With that said, copying Wordpress over isn’t actually that bad, so let’s think about doing the same (or equivalent result) thing just a different way. This is what I’d do:

First I’m going to make two assumptions:

  • Droplet A’s Wordpress database is named “wordpress”
  • Droplet A’s Wordpress installation exists in /var/www/html

So this is what I’m going to do then:

  1. Re-image Droplet B with our Wordpress one-click image.
  2. From Droplet B run: ssh-keygen and hit Enter until it stops prompting you.
  3. Copy /root/.ssh/id_rsa.pub from Droplet B to Droplet A’s /root/.ssh/authorized_keys file. Can do this by hand, copy/paste contents.
  4. SSH into Droplet A and run: mysqldump wordpress > wordpress.sql
  5. SSH in to Droplet B, let it run the initialization script for Wordpress.
  6. From Droplet B, run: cd /var/www/html && rsync -avz root@Droplet_A_IP:/var/www/html/ .
  7. From Droplet B run: cd /root && rsync -avz root@Droplet_A_IP:/root/wordpress.sql . && mysql wordpress < wordpress.sql

Boom, done. Droplet B is running an exact copy of Wordpress from Droplet A.

Jarland

Have another answer? Share your knowledge.