Maria Sharapova was made to work hard on her seasonal clay-court debut before eventually seeing off Lucie Safarova in the WTA Porsche Grand Prix.