Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How can i take image of my ubuntu running on a VPS and then make it run on my local machine? I have access to my VPS via ssh as root user.

Taking an image of it and making it run on local machine will help me to create staging/production server replica.

I have installed several application on my machine and it will be hard for me to replicate it manually.

share|improve this question
1  
What VPS technology are you using? Do you have access to the VPS host server? –  womble Aug 18 '11 at 11:53

2 Answers 2

It is possible,

try setting up another machine with a lot of disk space (at least enough for the size of your VPS and a host OS). Once you have done this you should perform the following actions:

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

After downloading the backup img from your server, put it on a (external) harddrive. Next launch an Ubuntu live disk. Create a new partition, on the hard drive you are going to put your system on. It should have the same size as your VPS is using.

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 and setup grub :

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

Make sure in fstab everything is correct

vim /etc/fstab

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

share|improve this answer

What I would do (never did, though):

  1. Use dd to create an image of your partition (you probably need another partition to store that image): dd if=/dev/sda1 of=/dev/sdb1/imagename.img
  2. Download that image
  3. Create a local partition and uncompress the image onto that partition (here you've got an example)
  4. Use that partition through virtualization

This steps seem pretty logical, but I'm affraid I have no detailed process available ;)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.