Tuukka Rask bounced back from a rare rough patch to salvage a win for the Boston Bruins on their California swing.

Rask made 26 saves for his NHL-leading fifth shutout two nights after being knocked out early, and the Bruins got a third-period goal from Carl Soderberg to beat the San Jose Sharks 1-0 on Saturday night.

‘‘That was Bruins hockey,’’ said Rask, who gave up three goals in less than 22 minutes in a loss at Los Angeles on Thursday. ‘‘That’s how we get points in this league. Sometimes we slip from it but today was a great example of how we need to play in order to get points. I'm really happy with the effort.’’

Rask gave up eight goals on the first two games of the trip as the Bruins were outscored 9-4 in losses at Anaheim and Los Angeles. But they rebounded in San Jose to sweep the season series and hand the Sharks just their second home loss in regulation all season.

Soderberg broke the tie with 7:35 remaining at the end of a broken play when Loui Eriksson’s shot was blocked by Scott Hannan. Soderberg got the loose puck and knocked it past Antti Niemi for his sixth goal to salvage the finale of Boston’s three-game California swing.

‘‘A goal’s a goal in this league,’’ Boston coach Claude Julien said. ‘‘You get some tough ones that go against you so every once in a while it’s good to have some go for you. That’s the breaks of the game, and sometimes you have to make them yourself.’’

Niemi made 21 saves for the Sharks, who had their six-game home winning streak snapped and were shut out at home for the first time since Feb. 9, 2013, in a shootout loss to Phoenix.