You will need to:
- Go through passport control
- Wait for your bags
- Go through customs
- Get yourself to T2 either using the shuttle bus that leaves outside arrivals or the SkyTrain which has a station near T1B East security.
- Check-in
- Go through passport control
- Go through security at your departure gate
5 hours should be enough time.
The main risks are a very late/cancelled inbound and/or delays at passport control/bag delivery.