There are different types of back exercises you can do to help work on a straight back and good posture, I'll name a few. Before I do though I want to point out that working on flexibility in your back, core, hips and shoulders will be AS IMPORTANT as working on strenght.
Deadlift / Bend over row: If you do these exercises with proper form you'll create a very strong back which will help keep your back straight.
Front squat: This is one most people wouldn't expect to see here but I'll explain why. When you properly do a front squat, you'll force thoracic extension. If you can't do this it's probably because you're hip flexors are too tight. You'll need to work on that to get a straight back.
Pull-ups: You can do many different versions of the pull up to work on your overall back. Make sure you focus on the fact that your shoulders are retracted and that you do proper form pull-ups. Don't force reps while swining and kicking up your legs, this won't help you get a good back.
Superman: This is a simple bodyweight exercise you can do on the floor without any equipment which focusses on strength and flexibility.