I accidentally broke my installation quite badly, but luckily I had some settings and other bits and pieces ready for just this occasion. Note that the following is for Debian based systems!
Step One – Get a list of installed packages
Once you have your machine set up more or less as you want it, export the list of installed packages to a file like this:
Step Two – keep the list safe!
Keeping the list safe is more important than keeping it up to date. I keep mine in my DropBox account with a few other essential items. Using DropBox means I can grab the file via the web if I need it in a hurry. Not much point if I needed to install DropBox before I could access the file!
Step Three – Recover the Backup
Bring everything back in one massive update if things go wrong:
sudo apt-get dselect-upgrade
Warning, the final step will probably take some time to finish, and while it is pretty good it won’t be perfect – you may want to include your apt sources in DropBox too. Personally I find it preferable to the manual option.