Cloning a Debian server
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:
- Installing the correct packages
- Cloning the configuration
- Copying all user files
- 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_selected.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 [1]] Debian installation image and install a minimal system. Copy the file containing the package selections (packages_selected.txt) to the newly installed system and:
$ cat packages_selected.txt | dpkg --set-selections
This will selected the packages that were selected on the server you want to clone. 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.