Clone the same Debian packages from another target

Sometimes we need to clone machines, for such use we may refer to rsync, and when we talk about debian package the debian package manager dpkg comes with some famous options that make our clone procedure very easy :
Let’s take an example :
So we have to clone the machine nibiru (machine to restore) from the machine maya (machine to backup):
Well On maya run:
$ sudo dpkg –get-selections > /tmp/dpkg.txt
Copy the dpkg.txt file to the target to restore system and run:
$ scp /tmp/dpkg.txt mezgani@nibiru:~/

On nibiru:
$ sudo dpkg –set-selections < ~/dpkg.txt
$ sudo apt-get -y update
$ sudo apt-get dselect-upgrade
et

Advertisements