Sometimes you need to backup a complete disk image. I’m using Linode for some things, and the other day I was shutting one of the nodes down. I wasn’t sure the node had any important data on it, so I had to make a backup.

The workflow described in the Linode Library is broken. It suggests running the dd command in the rescue console, directly over ssh. The problem seems to be that before you run the command to dump the disk to stdio, you have to interact with Lish, the Linode Shell, and select the right node etc.

First of all, trying to run the suggested command doesn’t work at all:

ssh: connect to host port 22: Connection refused

And when I actually managed to connect, I was greeted with the following error message:

[linode12345@london363 lish] Thu Feb  6 02:16:50 EST 2014
[linode12345@london363 lish] Linode Shell (lish) Console starting...
[linode12345@london363 lish] $TERM too long - sorry.
Your Linode isn''t running, or another console session is already active.

To make a long story short. First I did the following on my local laptop:

$ export TERM=screen-256color # lish didn''t like my long term
$ ssh -t linode12345

When connected to my linode, I did the following:

root@hvc0:~# mkdir backup
root@hvc0:~# sshfs backup  # mount a directory on my laptop''s password: 
root@hvc0:~# cd backup/
root@hvc0:~/backup# dd if=/dev/xvda | gzip -9 - > linode.img.gz
49807360+0 records in
49807360+0 records out
25501368320 bytes (26 GB) copied, 4247.53 s, 6.0 MB/s

Piping the image to gzip isn’t strictly necessary, but I knew the disk was mostly empty so I figured it would compress pretty well. Downloading things from Linode isn’t very fast for me, so this reduced the 26 GB image to 3.3 GB.

Blog Logo

André Laszlo


Back to Overview