Difference between revisions of "Cloning a Debian server"

From IridiaWiki
Jump to navigationJump to search
Line 12: Line 12:
   
 
<pre>
 
<pre>
$ dpkg --get-selections > packages_selected.txt
+
$ dpkg --get-selections > packages_server.txt
 
</pre>
 
</pre>
   
The machine on which you want to install the server clone has to be up and ready to receive a Debian fresh installation. Find a [http://www.debian.org]] Debian installation image and install a ''minimal system''. Copy the file containing the package selections (packages_selected.txt) to the newly installed system and:
+
The machine on which you want to install the server clone has to be up and ready to receive a Debian fresh installation. Find a [http://www.debian.org Debian installation image] and install a ''minimal system''. Get a list of all the packages installed on the new minimal system:
   
 
<pre>
 
<pre>
$ cat packages_selected.txt | dpkg --set-selections
+
$ dpkg --get-selections > packages_minimal.txt
 
</pre>
 
</pre>
   
  +
Now, change all occurances of "install" to "deinstall" on packages_minimal.txt, except hardware specific packages (e.g. for usb keyboards, network devices etc.).
This will selected the packages that were selected on the server you want to clone. In order to actually install the packages run:
 
  +
  +
Copy the file containing the package selections for the server (packages_server.txt) to the newly installed system and:
  +
<pre>
  +
$ cat packages_minimal.txt | dpkg --set-selections
  +
$ cat packages_server.txt | dpkg --set-selections
  +
</pre>
  +
 
This will selected the packages that were selected on the server you want to clone as well as remove any unwanted packages from the minimal install. In order to actually install the packages run:
   
 
<pre>
 
<pre>

Revision as of 18:19, 20 February 2006

Cloning a server an be necessary for various reasons, e.g. due to hardware failures and upgrades as well as after hacker attacks. Notice that in order to clone a server using the method described below, you need access to the server that you want to clone. Hence, it is a good idea to take the steps described below BEFORE a machine crashes or is compromised.

The cloning consists of four different steps:

  1. Installing the correct packages
  2. Cloning the configuration
  3. Copying all user files
  4. Loading all application data (databases, mail, etc.)

Installing packages

On the server that you wish to clone, you have get a list of installed packages:

$ dpkg --get-selections > packages_server.txt

The machine on which you want to install the server clone has to be up and ready to receive a Debian fresh installation. Find a Debian installation image and install a minimal system. Get a list of all the packages installed on the new minimal system:

$ dpkg --get-selections > packages_minimal.txt

Now, change all occurances of "install" to "deinstall" on packages_minimal.txt, except hardware specific packages (e.g. for usb keyboards, network devices etc.).

Copy the file containing the package selections for the server (packages_server.txt) to the newly installed system and:

$ cat packages_minimal.txt | dpkg --set-selections 
$ cat packages_server.txt | dpkg --set-selections 

This will selected the packages that were selected on the server you want to clone as well as remove any unwanted packages from the minimal install. In order to actually install the packages run:

$ dselect

And choose "Install". Don't worry too much about the various configuration options as you are likely going to overwrite during the configuation cloning.

Cloning the configuration

User files

Restoring application data