Earnshaw endured some embarrassing headlines in midweek after he missed a glorious second-half opportunity to claim a famous draw for Wales in the 1-0 defeat to England on Tuesday night.
With this Euro 2012 qualification disappointment still fresh in the memory, Earnshaw struck the post in the opening minute against Rovers at the Cardiff City Stadium.
However he completed a routine finish 15 minutes from time after captain Anthony Gerrard headed the Bluebirds on their way to a first league win in four.
Bottom-of-the-table Doncaster more than held their own for most of the match, but only have a solitary point for their endeavours this season.
Aron Gunnarsson returned from a spell on the sidelines to take up a place on the Cardiff bench as boss Malky Mackay stuck with the same XI that drew with Portsmouth before the international break.
Doncaster made two changes as Sam Hird and Giles Barnes made way for James O’Connor and James Coppinger.
Both sides wore black armbands in memory of Mike Dye, the Cardiff supporter who died after suffering head injuries in violent clashes outside Wembley ahead of Tuesday’s Euro 2012 qualifier between England and Wales.
Earnshaw was in the thick of the action inside the first minute, striking the post after Doncaster goalkeeper Gary Woods spilled a ball in from the left.
Kenny Miller might have given City the lead when he engineered space in the area and over in the 19th minute.
Doncaster were soon displaying their customer tidy build-up play and a slick exchange between Coppinger and Kyle Bennett resulted in the latter drawing a fine save from David Marshall with a 25-yard strike.
A more direct route almost gave Rovers the lead 11 minutes before the interval as a long clearance from Woods was allowed to bounce by the Cardiff defence and James Hayter volleyed goalwards to bring a reaction stop out of Marshall on his near post.
Earnshaw flew out of the blocks again at the start of the second half, forcing Woods into a sharp save with his feet.
But Cardiff found the breakthrough in the 51st minute after Tommy Spurr fouled Miller in a dangerous position.
Peter Whittingham delivered a sumptuous cross from the set play and Gerrard was on hand to glance a header into the bottom corner.
The contest remained even, but Cardiff eventually gave themselves breathing space with 15 minutes remaining.
Whittingham was the architect once more although he was a touch fortuitous after unleashing a shot from the right side of the box that deflected back into his path.
At the second time of asking he took the best course of action and found Earnshaw who applied the finish.
Both Whittingham and Earnshaw had chances to add gloss to the score in stoppage time but Doncaster avoided further punishment.