proverb

Hope for the best and prepare for the worst.

optimism

suggests that

One should be optimistic and expect the best, but also one should take precautions against adversities that might happen.