The Cubs trailed 6-3 after 4 1/2 innings but scored twice on back-to-back bases-loaded walks surrendered by San Diego in the bottom of the fifth, pulling to within a run. Chicago forged a 6-6 tie in the eighth when pinch-runner Tony Campana stole second and third with two outs and scored on Starlin Castro's infield hit.
Then in the ninth, Barney lined a two-out pitch from Dale Thayer (0-1) through a stiff breeze into the center field bleachers, giving the last-place Cubs their first series sweep of the season.
Barney finished 2-for-3 with three RBI and three runs scored while Steve Clevenger added a pair of run-scoring hits for the Cubs, who won a third straight game for the first time in 2012.
James Russell (2-0) earned the victory with a scoreless top of the ninth.
Carlos Quentin bashed a pair of two-run homers among his three hits for San Diego.
Biologists detail four new deep-sea 'killer sponges'
Pistorius testifies he didn't consciously pull trigger when he shot girlfriend