Script/tool to clone a ubuntu server

I have installed and configured a ubuntu server (installing additional packages and making modifications to some configuration files). Now I would like to install an almost identical system, which has just a different IP, hostname, or anything like these. Is there any script or tool that can automate this process?

I am not looking for something like Clonezilla, which makes an image clone. I am not looking for something like remastersys, which creates an ISO image. I would like something like this: http://www.debianadmin.com/clone-your-ubuntu-installation.html or this: http://ubuntuforums.org/showthread.php?t=525660 , but more complete and automatic.

Basically, this tool should scan the existing system and extract a list of packages that are installed. Then compare the configuration files on the system with the default configuration files of each package and generate diffs where they are different. However it should also identify the configurations that are different for each server (like IP, hostname, etc.) and give an option to customize them.

All this should be done automatically, and the output should be a very small sized "DNA" of the current system. Then a tool like debootstrap should be used to install the new system, and the changes that are described on the "DNA" should be applied to it: installing new packages and modifying their configuration files.


About the motivation:

I manage a virtual web server in cloud where I have made lots of configurations over time: related to security, different packages etc. Now, if I want to build another server that has the same function and purpose as the first one, the long and tedious way would be to go over all the installations and configurations again, and still I may miss something. I thought that maybe there is any tool out there that can make something like a diff between the current state of the server and the initial state of a just installed server. This diff would also help me to audit the current system, I don't exactly remember all the things that I have touched and messed in it.

Such a diff could also serve as a recipe that I can share with my friends, if they want to build a system like mine. It would be much more convenient and safe than passing around huge tarballs or images.


The tools suggested for cloning:

Some of the tools suggested are:

  • Mondorescue
  • Clonezilla
  • Remastersys
  • TKLBAM
  • Snap
  • Cobbler
  • Puppet
  • Cfengine
  • Chef

But none of them is suitable for my case.


If two systems have the same packages installed, and you make a diff of their /etc directories, you will basically get all the configuration changes between them (maybe not 100% of them but still very accurate). So, what I did to audit my system was this:

  • Install a minimal system with debootstrap (similar to what is described here: http://dashohoxha.blogspot.com/2013/02/how-to-set-up-chroot-environment-for.html).

  • Make sure that I install on the chroot system all the packages that are installed on the main system (as described here: http://www.debianadmin.com/clone-your-ubuntu-installation.html)

  • Make a diff between the /etc dirs of both systems.

Of course, this diff cannot be readily used to install and configure another system, but knowing where are the differences and what they are, can help to build a tklpatch (like this: https://github.com/dashohoxha/B-Translator/tree/master/tklpatch), which of course is not quite easy to be done and requires some work.

Then, I can distribute/publish this tklpatch and everybody can build easily a system quite similar to mine.