PHOENIX -- The Milwaukee Brewers strung together quality at-bats, got solid pitching and held onto a lead for once.
Not a bad way to close out what had been a frustrating series -- or head into the All-Star break.
"I thought it was a really nice ballgame," Brewers manager Ron Roenicke said. "After those last three, we obviously needed to come out with a win. A lot of good things happened."
The Brewers spent the first half of the season struggling with injuries and consistency. Against Arizona, they had trouble holding leads in three frustrating games in the desert.
Milwaukee prevented the sweep by roughing up Ian Kennedy (3-6) with a string of two-strike hits and a second straight strong outing by Peralta (7-9)
The hitting came early: Four runs the first two innings against Kennedy.
Carlos Gomez hit a two-run single in the first inning, Schafer drove in another run in the second with a sacrifice bunt and added a solo homer in the fifth.
Peralta, coming off his first complete game shutout, effectively worked around base runners all day, and the bullpen held after he left, helping the Brewers end a six-game losing streak to the Diamondbacks.
A nice finish to the first half for the Brewers with a much-needed break coming up.
"It's great to close out the first half like this and hopefully we can keep it going after the break," Schafer said. "We've had some guys banged up and these four days should be good for us to get ourselves back healthy."
Swept by the Dodgers earlier in the week, Arizona responded with three impressive victories over Milwaukee.
With a chance for their first sweep of the Brewers, the Diamondbacks fell flat, unable to bounce back after Kennedy's shaky outing left him stuck on 49 career wins for the seventh straight start.
Miguel Montero homered for the second straight game, but Arizona went 0-for-6 with runners in scoring position, failing to capitalize after getting the leadoff man on six times.
A dud to finish, yes, but the Diamondbacks still head into the break leading the NL West, 2˝ games ahead of the Dodgers at 50-45.
"We are in first place," Diamondbacks manager Kirk Gibson said. "We had a lot of trial and tribulations, but the team has hung in there well. We have stuck together well."
Peralta, who tossed a three-hitter against Cincinnati his last start, worked around base runners through the first four innings with the help of two double plays and a pickoff by catcher Martin Maldonado after Adam Eaton strayed too far off first in the third.
The right-hander extended his scoreless streak to 19 1/3 innings until Montero hit his first pitch of the fifth for his eighth homer.
Peralta stranded runners at second and third in the sixth inning and worked around another runner in the seventh. He allowed a run and seven hits and struck out eight.
"He's an emotional guy and you see it on the mound," Roenicke said. "You see when he's frustrated, but when he can regroup after being frustrated and make good pitches, that's what I like to see."
Kennedy's frustrations continued.
The right-hander has struggled with his put-away pitches, a big reason he's labored through the first half of the season.
Kennedy again had trouble putting hitters away against the Brewers, allowing four straight singles to open the game -- all after getting ahead 0-2 or 1-2.
The fourth one was by Gomez, who lined an 0-2 pitch through the right side for a two-run single and another run came in on a groundout by Maldonado.
Schafer drove in a run with a sacrifice bunt in the second inning and, after falling behind 0-2, led off the fifth inning with a homer that put the Brewers up 5-0.
Kennedy allowed five runs and nine hits in 6 1/3 innings, the second straight start he's allowed five earned runs. He hasn't won since June 1 against the Cubs.
"A lot of crazy things going on," said Kennedy, 0-3 with a 6.58 ERA his past seven starts. "I am not pitching to my abilities every once in a while, not throwing well. Very inconsistent would probably be the word."
Arizona 2B Aaron Hill ended a 0-for-16 streak with a single in the fourth inning. ... The Brewers have more than 70 stolen bases (77) before the All-Star break for the first time since swiping 87 bases in 1993. ... Diamondbacks 3B Martin Prado made a pair of diving stops -- one in each direction -- to take away hits from Maldonado in the first inning and Jeff Bianchi in the sixth. ... Arizona opens the second half of the season at San Francisco on Friday. Milwaukee faces Miami at home the same day.