Bumgarner (11-5) allowed just two hits -- including a seventh-inning homer to Chris Snyder -- while striking out five and walking two. He improved to 7-1 at AT&T Park on the season.
"It's pretty incredible what he does and the poise he has out there," said Giants manager Bruce Bochy. "For most of the pitching staff and the players, you're always gonna be a little bit more comfortable here and you usually do pitch better at home."
Posey's blast came in the first inning while Joaquin Arias and Justin Christian both added an RBI in the second for the Giants, who had lost seven of nine prior to the All-Star break.
Wandy Rodriguez (7-7) took the loss for the Astros, giving up four runs on seven hits over six innings.
Angel Pagan, who capped the scoring with a sac fly on the heels of Pablo Sandoval's triple in the eighth, led off the second inning with a base hit. Brandon Belt followed with a single before Arias delivered an RBI grounder to left field. Christian's groundout two batters later made it 4-0.
"They squeezed out some hits and squeezed out the early runs," said Snyder.
Javier Lopez, Sergio Romo and Santiago Casilla combined for two scoreless innings of relief in the win.
Bumgarner is 15-2 over his last 18 starts at AT&T Park...He has gone at least six innings in all but two starts this season...Rodriguez has gone at least five innings in 48 consecutive starts, marking the longest active streak in the National League.
For more on the Giants, head over to McCovey Chronicles.