Files (music, photos, videos, etc.) can be saved to a SD card, a cloud or google account, a computer, etc. The same goes for contacts, data files, etc.
Apps, however, cannot be saved. So any apps you have installed would be wiped and once the phone is reset you would have to reinstall said apps.
This is while I mentioned saving data files. For 'some' apps, you can save the files that are with them that hold the data the app uses. Not all have or allow this, so it is hit and miss, but you can go through the phone's file manager app to locate them. Or connect the phone to a computer via USB cord and then search for the files through the computer.
In regard to messages. Well if you mean plain old text messages (not messages through the 'messenger' app), then you can forward, via email, all those text to yourself (depending on how many there are that can take a while). However there are limitations to that as any message over approximately 140 characters won't show up. However, I know there are some programs out there (computer programs) that can copy the texts from the phone, while it is connected to the computer via USB. I can't think of specific ones off hand, but that would be the route I would suggest.
Also, in the future, you should make regular backups of the things you want, and not leave it all on the phone until you either have to move it all (like now) or your phone dies, is lost, stolen, etc., and you lose everything on it.