If your main issue with your fence is the fact that it is leaning, the good news is that you do not have to replace any part of it unless it is showing damage.
If it is leaning, you have to dig around the post until you reach the base, which should be concrete. If the post is damaged or rotted, you will need to replace it.