Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have Redhat Linux Server with Apache, Oracle and PHP. I am using this server as a production server, and I want to create a new test server with the same configurations/product versions as the production server. Is there any way to copy all the installation/configurations from production and install/copy on the other server.

share|improve this question

migrated from Jun 15 '11 at 5:46

This question came from our site for computer enthusiasts and power users.

Assuming you've installed everything from packages from the official repositories the process would be:

  1. Get a list of packages on the source server
  2. Take a backup of /etc on the source server
  3. If you have any other config to copy, like web pages/scripts under /var/www and stuff in /home and /root back these up too
  4. Perform a fresh install on the new machine
  5. Use the package list found in step 1 to get the packages in line on the new machine
  6. Copy replace the contents of /etc with the backup from the first machine but be careful of files that will need to vary if the machines are going to be on the same network like /etc/hostname and /etc/samba/smb.conf.
  7. Restore other files/settings if more were backed up in step 3
  8. Repeat steps 4 through 7 for each machine if more then one is needed

To get the package list in step 1 under Debian or similar use sudo dpkg --get-selections '*' > selection.dpkg, and to install the packages on the new machine in step 5 use sudo dpkg --set-selections < myselection.dpkg --set-selections < myselection.debconf followed by sudo apt-get -u dselect-upgrade. If you hit any errors, make sure you have the debconf-utils package installed with sudo aptitude install debconf-utils (in fact it would be worth running this before you start just-in-case as it'll just do nothing if the package is already present).

I'm not overly familiar with yum (as used by RadHat and such instead of dpkg and apt*), but I presume it has similar features - check the documentation or hang around to see if a yum expert posts an answer to this question (or a comment to this answer) with details. yum list installed may be where to start.

It is also a good idea, though not required (the configuration should be present in the backup of /etc anyway), to keep record of the package configuration selections and apply that to the new machines. That way you'll not risk accidentally reverting something to default if you do something that forces a package to be reconfigured. On Debian-a-likes add sudo debconf-get-selections > selection.debconf to step 1 and run sudo debconf-set-selections < myselection.debconf before step 5.

Edit, re: Oracle:

As you list Oracle as one of the things you have installed, you don't have everything installed from packages (unless Oracle is installed via a custom repo in which case add that repo to the new server's config before step 5 and it might work). You'll need to consult the Oracle documentation (or an Oracle expert) to see how to backup all the required files and configuration and restore this to the target machines.

Alternately you could just take an image the machine's hard-drive(s) (with something as simple as dd, or a more specialised disk/filesystem cloning tool) and restore the image(s) to the destination machines, followed by machine-specific updates such as changing hostnames. This will likely take longer and require more storage space (though may be easier) as you are potentially copying around the images of massive drives.

share|improve this answer

You can replicate the set of installed packages like this:

  • On the production server, get the output of rpm -qa:

    rpm -qa > list-of-packages
  • On your development server, pass that list of packages to yum:

    yum install $(cat list-of-packages)

This will work well as long as your development server does not already have a newer version of the package installed (because yum doesn't like to downgrade packages).

As Mr. Spillet said, if you have packages that have been installed outside of your normal list of repositories you'll have to deal with those by hand.

In general, replicating the configuration files is a manual process unless you have taken steps to record on the production server which files have been modified from their stock configuration. We often use a version control system (like git) for this purpose. Assuming that all your installed packages are well behaved, you might be able to do something like this to get a list of configuration files:

rpm -qac

That's -q for --query, -a for --all, and -c for --configfiles.

Assuming ssh access between the two systems, you could then do something like this to copy them all over to your development server:

cd /
ssh production 'rpm -qac | cpio -o' | cpio -iuvd

...however, I'm not sure that I'd recommend this in process, because it's liable to overwrite something on your target system that has system-specific information (i.e., that is somehow hardware-specific). If you adopt some sort of version control this becomes less problematic (because you can identify changes and revert them as necessary).

share|improve this answer

Your Answer


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