3

I have a dedicated (virtual) server, to which I have only SSH access to. I would like to backup/clone the server to my local virtual machine.

I tried to backup with tar all the essential files, but then I struggled with restoring it on a new Virtual Machine. I didn't manage to make my new VM bootable.

So any help is welcome.

Server OS version ubuntu 10.04.3

EDIT

Virtualization platform - OpenVZ

3
  • 1
    What type of virtualization is it? If it's something like OpenVZ/Rackspace/Amazon, then you are likely SOL...
    – Soviero
    Jan 14, 2012 at 14:10
  • @Kevin The answer varies depending on the virtualization platform either way -- we definitely need to know what kind of virtualization platform is being used.
    – voretaq7
    Jan 14, 2012 at 21:26
  • 1
    Virtualization platform - OpenVZ Jan 15, 2012 at 14:14

2 Answers 2

5

It is possible,

try setting up another machine with a lot of diskspace (at least enough for the size of your vps and a host OS)

Lets say this disk is called /dev/sda where your data is stored on.

then dd if=/dev/sda | ssh username@placetobackup "dd of=/directory_of_backups_on_ssh_server/backupfile.img"

Now after downloading the backup img from your server, put it on a (external) harddrive. Next start up an ubuntu live disk. Create a new partition, on the harddrive you are going to put your system on that has the same size as your vps and all its partitions.

Lets say this disk is called /dev/sda

Lets say our external disk with our backup img is called /dev/sdb

 parted /dev/sda mklabel msdos

use cfdisk to partition your drive /dev/sda

Next mount your harddisk to your live environment

 mount /dev/sda /mnt 

Next mount your sdb

mkdir /oldImage; mount /dev/sdb /oldImage 

cd /oldImage

Next we copy everything with all rights to the new image

 find . -xdev | cpio -pm /mnt

Next mount some folders :

mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys

Chroot yourself :

 chroot /mnt 

Install a kernel if you used virtualisation software like Xen or openVZ and setup grub :

apt-get install linux-image-2.6-amd64 grub
grub-install /dev/sda
update-grub

Make sure in fstab everything is correct

vim /etc/fstab

Next shutdown the system, boot from the harddrive we copied everything to.

3

You may want to look in to remastersys -- It's a pretty decent tool for making Ubuntu-system install disks.
If you use remastersys in backup mode You'll wind up with an installer ISO that gives you a clone of the machine you backed up (there may be a few differences -- for one I don't believe remastersys backs up SSH keys, though I could be wrong -- so expect to have to do a little manual tweaking).

There are two advantages to this approach: One is you'll be using Ubuntu's ubiquity installer -- It'll pretty much guarantee you a bootable system with very little effort. The other is you'll have an installer CD that lets you easily clone the system in the future.

There is one big potential disadvantage to this approach in your case: Your virtualization solution needs to support booting from an ISO. VMWare and Hyper-V definitely do, I don't know if Xen or OpenVZ do, and I'm almost certain that the Rackspace/Amazon type cloud virtualization platforms don't.

1
  • Citrix xen does, but regular Xen requieres debootstrapping. OpenVZ requires using templates. Qnd your solution might have saved me many hours :p Jan 15, 2012 at 21:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .