Sync your phone with iTunes (which backs it up and transfers any purchases to your iTunes library). Then import all your photos to your computer to be safe (see http://support.apple.com/kb/HT4083) and back up your contacts (by, for example, syncing them with iCloud by going to Settings>iCloud and turning Contacts to On). Then you should be able to safely update. (Your music should already be in your iTunes library.) Be careful to pay attention to the progress information you see at the top of iTunes, and on your iPhone screen so you do not unplug your phone until the update is complete.