*

TSX ends up 161.77 points, or 0.8%, at 20,503.21

*

Posts its highest closing level since Dec. 1

*

Tech sector climbs 2.4%

*

Magnet Forensics ends 13.9% higher

Jan 20 (Reuters) - Canada's main stock index rose on Friday to its highest closing level in more than seven weeks as technology shares rallied and higher commodity prices boosted resource shares.

The Toronto Stock Exchange's S&P/TSX composite index ended up 161.77 points, or 0.8%, at 20,503.21, its highest closing level since Dec. 1. For the week, the index was up 0.7%, its third straight week of gains.

Major U.S. stock indexes also closed higher, paced by gains for the technology-heavy Nasdaq after Netflix reported quarterly earnings.

"The techs are having a decent bounce back ... but it still feels like the commodities and cyclicals are going to be a nice place to add some outperformance," said Greg Taylor, a portfolio manager at Purpose Investments.

The Toronto market's technology sector climbed 2.4%, helped by a 5.6% gain for the shares of e-commerce giant Shopify Inc .

Energy was up 0.4% and the materials group, which includes precious and base metals miners and fertilizer companies, added 1.1%.

The price of copper rose 0.6%, while gold remained near its highest level in nine months and oil settled 1.2% higher at $81.31 a barrel.

Heavily-weighted financials advanced 0.7% and industrials ended 0.8% higher.

Canadian retail sales dipped 0.1% in November from October. Still, that beat analysts forecasts for a decline of 0.5%, while a flash estimate showed sales rebounding 0.5% in December.

"It does show that the Canadian economy is still holding up reasonably well," said Colin Cieszynski, chief market strategist at SIA Wealth Management. "And, inflation is coming down, so that's all encouraging."

Thoma Bravo will buy Canadian software firm Magnet Forensics Inc in a C$1.8 billion ($1.3 billion) deal, the company said, as the private equity firm bolsters its cybersecurity portfolio to tap into rising demand.

Shares of Magnet Forensics ended 13.9% higher. (Reporting by Fergal Smith; Addditional reporting by Shristi Achar A and Johann M Cherian in Bengaluru; Editing by Shailesh Kuber and Alistair Bell)