Always remember that when you carry a backpack, it's the whole of your upper body that has to take the weight.
If the weight is only on the shoulders, you will eventually end up with with a painful back or shoulders irrespective of how strong you are.
For this, the first thing is to make sure you are carrying your backpack properly.
Few things to consider: Wear a backpack that has a hip belt.
Offloading a bit of the backpack weight on the hip helps to reduce the strain on the upper body.
Pack the backpack such that the heaviest items are closest to you.
The farther the heavier items from your body, the more the strain on you (the center of gravity shifts away from your body and thereby adding more strain on you).
Tighten the straps such that the weight gets distributed properly beween your shoulders/chest and hips.
Do not overload any of these.
The straps should not be loose.
If your shoulder straps are loose, the bag will move away from your body and will pull you backwards.
Adding a lot of strain on your back muscles.
If your hip straps are loose, the bag will keep sliding down and will cause your shoulders to take all the weight.
Posture can be compromised either due to habit (eg sitting for long in front of a computer), or due to a wrongly fitted backpack.
So make sure you consciously monitor your posture while you hike with your backpack.
Having said that, some of the exercises that can help: Planks (engages your abs and glutes).
Crunches (engages your abs).
Leg raises (engages your abs and hamstrings).
Negatives/pull-up holds (helps your shoulders).
The idea is to strengthen your core (mostly your abs) to allow for your body to not offload the whole weight on the back.
outdoors.stackexchange.com/users/2066/Ricketyship
2 weeks is not alot of time to prepare.
Try to do squats and rows.
And box-step-ups with a load on your back (gradually increasing).
My scheme looks like this:3 times per week I do 5 sets of 5 reps of squats, and every other training I do rows (5x5) or box-step ups (8x3, per leg).
outdoors.stackexchange.com/users/4220/Gudgip
Core exercises.
Your abs are the bowstring to your back, if you have weak abs, you'll feel it in your back first.
Wearing a heavy bag puts added stress on you back, which engages you abs, but we as homo-sapiens are lazy by nature (which is why we evolved to walk upright), so when we put extra stress on our backs, we tend to compensate by adjusting our posture so our frame takes most of the load, instead of the muscles, this is especially true when we're tired from hiking all day.
When you go on your hike, make sure your bag is adjusted properly for starters, then while you hike, just be conscious of keeping you abs engaged.
Don't over do it, don't flex like crazy, just a little tummy tuck will be enough to spare your low back a lot of grief.
Planks and pushups are good exercises to help build core strength.
Posture.
If you're suffering from upper back pain, then your posture is usually to blame.
Being hunched over watching the ground while the straps of your bag pull on your shoulders is one way to get a serious ache between your shoulder blades.
Again, make sure you bag is properly adjusted and that most of the weight is being carried by your hip belt, and ensure your bag is properly balanced so it isn't pulling you over backwards.
outdoors.stackexchange.com/users/4148/ShemSeger
Not going to strengthen much in two weeks.
But you can get your back and shoulders used to weight and fit of the pack.
I would go for as many short to long hikes as you can and would not overload the pack as you don't want to strain your back.
Take a few short hikes with a full weight load at about the 1 week mark to see how things feel.
outdoors.stackexchange.com/users/6728/paparazzo
Backaches are part of life with backpacking until you have a pile of experience.
Causes Compression.
You are carrying more load than you are used too.
This squeezes your vertebrae together.
This usually isn't the cause unless you are older, or you are carrying excessive loads.
Twist combined with compression.
The usual cause.
Back is very strong if you keep it in a straight line (for a somewhat odd value of straight)
You're adding a load to your back.
This tends to pull your shoulders back, and arch your back in the opposite direction you are used too.
Your abdominal muscles compensate -- or try to.
If they succeed, you have sore abs, but no sore back.
If they fail you have really sore abs and a sore back.
Fixing it:
Work on your abs.
Situps, crunches, oblique crunches.
Two weeks is pretty marginal.
Wear your pack with a facsimile of your load for the trip.
Try getting out for an hour a day.
2-3 hours on weekends.
Wear the shoes you will wear on the trip.
Practice walking as if with a stick up your butt.
This will reduce the twisting that happens on your back.
Preventing it:
Google 'making my pack lighter' If you can shave 10 lbs off your pack, you will enjoy your trip a lot more.
outdoors.stackexchange.com/users/2157/Sherwood Botsford
I will go hiking in 2 weeks. Are there any exercises for preparing for it, as last time I carried my pack on a hike for the whole day, my back started to hurt.
Are there any exercises that will strengthen my back to prepare for a day hike?
outdoors.stackexchange.com
<hiking><exercises>
outdoors.stackexchange.com/questions/19008
outdoors.stackexchange.com/users/15134/Salman sadiq
Do core exercises, including ab training, planks and push-ups.  If you have weak abs, you'll feel it in your back first. Squats and rows are also helpful. Get your back and shoulders used to weight and fit of the pack.  Always remember that when you carry a backpack, it's the whole of your upper body that has to take the weight, but you have to make sure you are carrying your backpack properly. Pushups and planks to build core strength, squats and rows as well as getting used to the backpack are all helpful.
You should build core strength with planks and pushups. Get used to the backpack to ensure proper carrying, do squats and rows.