LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Creating a "ghost" of a live webserver? (https://www.linuxquestions.org/questions/linux-server-73/creating-a-ghost-of-a-live-webserver-893658/)

Zippy1970 07-25-2011 11:12 AM

Creating a "ghost" of a live webserver?
 
I would like to run a copy of my live webserver in a Virtual PC on Windows so whenever I need to install new stuff on my webserver, I can "practice" first on the virtual copy.

It doesn't need to be an exact copy: I'm not really interested in having a copy of all domains on the webserver.

Is there a way to do that without having to take the webserver offline?

Blue_Ice 07-25-2011 12:45 PM

You could use a p2v tool to create an image, but you need to read up on the possibilities for Virtual PC. I don't know how Virtual PC works.

Zippy1970 07-25-2011 02:03 PM

I already have Debian running in Virtual PC. It's just not a copy of my webserver... I will look into the p2v tools.

dafydd2277 07-25-2011 05:24 PM

Do you keep your web servers under version control? How about your apache configuration files? If so, you can just check out the files into the virtual, and maintain good copies back and forth.

jefro 07-25-2011 10:08 PM

A p2v may help but not really needed. A dd of the drive ought to create a raw file, then use qemu-img to convert to a vpc hard drive format.

Almost any clone type of deal should work also. You can clone it to a file or set of files then make a new vm. Then boot to some live media to return the files to the new blank drive.

Use any tool for an real machine. A vm is no different.

If it is already a virtual machine then just copy it to some place and run it from there but be sure to disable network before you boot it.

Zippy1970 07-26-2011 04:53 AM

Quote:

Originally Posted by jefro (Post 4425111)
A p2v may help but not really needed. A dd of the drive ought to create a raw file, then use qemu-img to convert to a vpc hard drive format.

Heh, that's exactly what I'm looking at right now (dd + qemu-img). :)

Zippy1970 07-26-2011 05:19 AM

Ok, I actually started to create a ghost using dd until I realized this isn't going to work. My webserver is actually in a data-center - a two hour drive from where I live. The disk I want to ghost is 160Gb in size, meaning the image will be 160Gb as well. I realize I can compress this with gzip/bzip but that will still leave me with a file at least 70GB in size (that's the total size of files I know it can't compress any further (zip files, jpgs, etc).

I have a very fast internet connection at home so I should be able to download that in about 2 hours. Only problem is, that will eat up precious datatraffic from my server (I have a 500Gb monthly limit).

There's a lot on that drive I'm simply not interested in. Entire folders containing huge zip files or thousands of images. If I somehow can exclude those, I'm sure that what's left will not be larger than a few GB.

So is there another way besides dd/qemu-img?

Zippy1970 07-26-2011 05:26 AM

Hate to make this a one-man-show but I also just realized the drive has 5 seperate partitions:

1: /
2: /usr <- contains all hosted domains and the bulk of the data on the drive
3: /home
4: /var
5: /tmp

So I might get away with just dd-ing the 1st partition (about 1GB), then tar-ing 3, 4 and 5.

Right?

Zippy1970 07-26-2011 11:05 AM

Quote:

Originally Posted by Zippy1970 (Post 4425393)

So I might get away with just dd-ing the 1st partition (about 1GB), then tar-ing 3, 4 and 5.

Yeah, that will not work since that doesn't copy the boot sector... :(

So any other solutions?

lrtward 07-27-2011 12:32 PM

I have a similar setup and I installed apache, php, mysql, etc. on my "play" server. Got it all configured.

Now I have a nightly rsync job that runs and syncs /var/www/html from my production server to my "play" server. You can easily exclude portions of the website (videos, documents, etc.) with rsync so that you're not moving too much data.

Zippy1970 07-27-2011 01:08 PM

Quote:

Originally Posted by lrtward (Post 4426863)
Now I have a nightly rsync job that runs and syncs /var/www/html from my production server to my "play" server.

I had already tried rsync but for some reason it did not work. After the rsync, the installation on the virtual machine gave some weird error and started a BusyBox shell instead.

This is what I used:

Code:

rsync -vrpoglHDIt --exclude=/proc --exclude=/sys --exclude=/tmp --exclude=/etc/fstab --exclude=/usr/mysql --exclude=/usr/domains --exclude=/usr/backups --exclude=/var/cache --exclude=/var/log --progress (my webserver's IP):/ /


All times are GMT -5. The time now is 10:41 AM.