Once you have bought apps on the iTunes store, it remembers which one you bought. If you go through the process of buying the same ones again using the same iTunes account, after the step where you confirm you want to buy it, iTunes will report that you already own the app and will ask if you want to download it again.
I haven't tested this with purchased music but I expect the same rule applies.
Therefore what you need to do is write down a list of all the apps on your iPhone, and all the purchased music on your iPhone, before plugging it into the computer. (Plugging it in is likely to wipe everything due to iTunes syncing from an empty library.)
Apple doesn't provide any method of copying music from an iPod or iPhone to a computer. There are third party tools which can extract music from an iPod Classic, Nano or Shuffle, but I don't know of any that can do it with an iPod Touch, iPhone or iPad.