Baseball legend Barry Bonds was sentenced Friday to two years of probation for an obstruction of justice conviction in connection with his 2003 testimony to a federal grand jury investigating pro athletes’ illegal steroids use.

Bonds, who arrived at court with his mother and family, was sentenced to 30 days of house arrest and two years of probation and was also fined $4,000 in a San Francisco federal courtroom near the ballpark where he broke Hank Aaron’s major league home run record in 2007.

Federal prosecutors had wanted Bonds, 47, to serve 15 months in prison, according to a sentencing memo filed in court earlier this month.

The testimony that led to Bonds’ conviction came when a grand jury prosecutor asked him whether Greg Anderson, Bonds’ former personal trainer, sever gave him “anything that required a syringe to inject yourself with.”

Bonds told the grand jury that only his personal doctors “ever touch me,” and he then veered off the subject to say he never talked baseball with Anderson.

In closing arguments two weeks ago, a federal prosecutor said Bonds lied to the grand jury because he knew the truth about his steroids use would “tinge his accomplishments” and hurt his baseball career. Defense lawyers had argued that Bond’ thought the creams and ointments Anderson was giving him were made of flaxseed oils.