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.

link|improve this question

20% accept rate
1  
What VPS technology are you using? Do you have access to the VPS host server? – womble Aug 18 '11 at 11:53
feedback

2 Answers

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 ;)

link|improve this answer
feedback

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)

then dd if=/dev/hda | 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 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 harddrive we copied everything to.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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