Recover Your Data From Stopped Google Cloud Compute Engine Instance

Murat Gözel
Code with Benefit
Published in
2 min readNov 10, 2016
what i feel after recovering

Everyone buy and manage their own server instances today with cloud technologies. You don’t even need a physical access to the server. Because you can do almost anything remotely. As Google Cloud is one of those cloud providers, gives a wide range of services for server administrators and app developers.

I am going to write about recovering things. Because if you don’t have physical access to the server, accessing your data under hard circumstances can be challenging.

I have experienced this kind of a situation a little time ago. There was an upgrade of ubuntu version and i accidentally closed the ssh window while its upgrading. This is one of the worst things can happen to your server. Because there is no operating system files or they are not configured yet. So impossible to start server…

Started to think about recovering data after understand that starting the server is impossible. Did some research on the internet but none of them helped me. There is no way to access to the data on the server by logging in with serial port or by taking a snapshot.

What i found is a bit tricky solution that Google Cloud provides as a feature when you are creating new compute engine instance. That feature is attaching stopped server data as a disk to new compute engine instance!

First, you need to take a snapshot of your crashed server. Then create a new instance and attach your snapshot as a disk to the instance. Like the screenshot below:

attach your crashed server data as a disk to your new compute engine instance

Now, you are able to access all of your data by logging in to your new instance and mounting your attached disk. Here is step by step instructions:

  1. First create a directory to mount your attached disk to a folder. Do that by typing:
    sudo mkdir -p /mnt/disks/mount_directory_name
  2. Find out the name of your attached disk. Do that by typing:
    ls /dev/disk/by-id
  3. Now mount your attached disk to your newly created folder:
    sudo mount -o discard,defaults /dev/disk/by-id/your_disc_name /mnt/disks/mount_directory_name
  4. Let’s grant write access to all users:
    sudo chmod a+w /mnt/disks/mount_directory_name

Thats it. You are now able to access all your data (even database backups). You can browse it just by browsing in a regular server. Just zip it and download with sftp client.

--

--

Murat Gözel
Code with Benefit

Freethinker / Maker / Software Developer / Designer / Advertiser