Should the be upper case in these sentences?

During his administration, an act was signed forming two railroad companies, the Union Pacific and the Central Pacific.

Lincoln was president during an important part of our nation's history, the Civil War.

Your capitalization is correct.

However, President, when referring to the U.S. presidency, used to be capitalized, but I think the modern style is not to capitalize it. Refer to your book or style manual.