I try to stay in shape with a good workout 3 days a week. Then, leading up to a big hike, I'll bike to work (8 mile RT) often, maybe bike on weekends. And also this:
Before a big day hike: No more than a week ahead, I'll go and hike something nearly as far as the planned hike, but less strenuous: less altitude or distance, but I try to do 2/3 or 3/4 of the planned hike in intensity.
Before a backpack: I load up my backpack with gallons of water and carry it every other night just go get the feet, shoulders and joints accustomed to doing that. First time it really hurts. Each subsequent time, it gets easier and I walk faster. I usually do these walks late at night so too many people don't see me and wonder at the kook walking around with hiking poles and a big pack.

...I have a big backpack trip coming up starting Sunday, so I'm carrying 4 gallons around. Did two miles last night.