A Bakersfield man was sentenced to two years in federal prison for breaking into a Caliente post office with a hatchet.