This small guide is meant for those who need to
- clone an existing server/desktop the hard way (for those who lack virtualization tools)
- start from scratch with all packages previously installed (with or without maintaining the personalized settings)
- Get the current installed packages on the main machine: dpkg –get_selections > installed_packages.txt
- Make a copy of your old /etc/apt/sources.list and copy everyting from /etc/apt/sources.list.d/* onto your new machine
- Still on the new new machine, make sure you install dselect: apt-get install dselect
- Update to check for missing keys: apt-get update
- And add the missing keys: apt-key adv –keyserver keyserver.ubuntu.com –recv-keys XXXXXXXX
- Update again: apt-get update
- Register the new packages: dpkg –set-selections < installed_packages.txt
Now the fun part – use dselect to install the missing packages:
- dselect update
- dselect install
If you’d like the same personalized settings, simply copy the config files and folders from your /home/user located on the old machine -> onto the new machine. Same rule applies for other programs (apache, fpm, postfix): copy all files from /etc/apache, /etc/postfix and so on onto the new machine. For the future, using rsync or something similar might come more in handy.
This was the ‘hard way’ of cloning a server. Since the best sysadmin is a lazy sysadmin, you might want to consider Chef/Puppet/Ansible/SaltStack or any virtualization & cloning tool.