Install apt-clone by entering the following commands in the terminal:
sudo apt update sudo apt install apt-clone
Script to create state bundles
This package can be used to clone/restore the packages on a apt based system. It will save/restore the packages, sources.list, keyring and automatic-installed states. It can also save/restore no longer downloadable packages using dpkg-repack.