Linode.com provides a great service but it was time to retire an old node. After archiving all the data using rsync, I decided that I wanted to make a copy of the disk over ssh so I could mount it locally or re-upload it if I ever needed to restore. This process was really overkill for my application but I wanted an extra back up after last months event.
Step 1. I resized the disk image to make it smaller and get rid of the unneeded free space.
Step 2. I rebooted the Linode in ‘restore’ mode which basically loads a small instance of Finnix (Debian based – really tiny distro). You can use apt-get to install packages to Finnix but your space is limited. On Linode, ssh is not running and root does not have a password, so you will have to use the following commands through the console to get you up and running.
passwd #sets the root password /etc/init.d/ssh start
Step 3. Now you should be able to go over to your local machine and start the command to copy.
ssh -C [email protected] "dd if=/dev/xvda " | dd of=/home/whereyourwantit/linode.img
What this does is it creates a ssh connection with compression enabled to start sending your hard drive over to the local computer. Depending on the size of the drive, this could talk a little while.
One important note – in your .know_host file you might already have a key associated with the the ip/domain combination. You will need to delete that out of ~/.ssh/.known_hosts before being able to proceed.
Step 4. Wow you have your image and you are probably on a mac. Fantastic – since the filesystems are different. But no stress, load up your virtual box, mount your shared folder (if you can get guest additions to not be a pain) and then mount your image as the link linode suggests.
mkdir linode # creating the mount point mount -o loop linode.img linode ### Once it is mounted you should be able to traverse it like a normal file system. ls linode/ #exposes it all
Tomorrow I will try to upload the img back to Linode. Help me compile linux tips.
Update: Uploading the image back to Linode was a success
This process would be different if you were using a non-Linode image or you were trying to make the image work in a different virtual environment.
I started by creating a fresh Linode instance and then I created 2 disks (one for image and one for swap) after picking the datacenter.
Next, I created a new configuration profile. I set xvda to my primary disc and xvdb to my swap.
Now I start the Linode in recovery mode and basically repeat the steps above including setting the password and starting ssh in Finnix.
To copy the image to Linode:
dd if=/directoryto/linode.img | ssh -C [email protected] "dd of=/dev/xvda"
Then I reboot and I have a cloned version of the Linode I deleted yesterday up and running.
***Again disclaimer – this is probably not the best/most efficient way to back up your server.