While Carlyle's writings frequently touched upon themes of honesty and hard work, the exact phrase doesn't appear in his published works. It's possible that it emerged from his lectures or conversations, or was a common saying during his time that became associated with him.
Regardless of its origins, the phrase is a powerful reminder of the importance of integrity and perseverance.