This comes from a question a member of our community made, here is his question.
it would be a Good Thing to have a nifty tool in the spirit of aptoncd that will let you automate the process of getting your system back to where it was, or cloning an existing system. What I'd like to see would basically work like:
1. Build a list of packages installed on the system;
2. Remove from the list any packages unchanged from the original install medium;
3. Pull down copies of those packages and cache them (not in the /var/cache/apt tree);
4. Build a DVD or CD, or set thereof, to hold the packages (an external hard-drive option would be lovely);
5. Finally, also back up your /etc/apt/ directory to the same media.
This way, reinstalling/cloning your current system is easy:
1. Do a default/simple/quick install of your distro onto the PC;
2. Put the (first) disk with your packages into the drive;
3. Run a shell script that whacks over your saved /etc/apt onto the system and then installs all the debs via dpkg or similar)
This way, I could easily give my new-to-Linux friends who've commented on my specific install a no-brainer way to recreate it; install and then update from the media. No network immediately needed, which would solve problems with things like initially quirky wireless chips (e.g., Broadcom).
The complete comment is here:
Well I do not have automate way to do this, but after searching around I have found this.
First get to know which packages are installed on your Linux
aptitude search '~i' > /tmp/installed.txt
This is going to list all packages installed on your Linux, the ones installed by you and the ones automatically installed as dependencies, those ones identified with an A.
Get the names of the packages
cat installed.txt | awk '{print $1,$2,$3}' > /tmp/installed2.txt
This is going to erase the comments' column.
grep -v A installed2.txt | awk '{print $2}' > /tmp/installed3.txt
This is going to copy only the "installed by you" packages and not dependencies. You can work just with this file, and let the cloned Linux to resolve the dependencies and download them from the web, but if you have slow or no Internet, it is better to carry the dependencies also, so lets add them.
grep A installed2.txt | awk '{print $3}' >> /tmp/installed3.txt
Now on installed3.txt we have all the packages needed to recreate our Linux, lets now download them, to create then the CD or DVD.
Download the desired packages
for i in $(cat /tmp/installed3.txt) ; do packages+="$i " ; done
aptitude download $packages
Once that is done, we can use again, How to: aptoncd