Backup :
# backup list of installed packages
dpkg --get-selections | grep -v deinstall > backup-packages.txt
Restore :
# mark all packages as "deinstall" except the essentials one so you have a very low-level Linux system
sudo dpkg --clear-selections
# restore your backup
sudo aptitude install -y $(cat backup-packages.txt | awk '{print $1}')