I heard the Prophet ﷺ say, more than once or twice, "When a servant is engaged in righteous deeds and is then prevented from them by illness or travel, there is recorded for him the like of what he used to do when he was healthy and at home."
حدثنا محمد بن عيسى ومسدد المعنى قالا حدثنا هشيم عن العوام بن حوشب عن إبراهيم بن عبد الرحمن السكسكي عن أبي بردة
سمعت النبي ﷺ غير مرة ولا مرتين يقول إذا كان العبد يعمل عملا صالحا فشغله عنه مرض أو سفر كتب له كصالح ما كان يعمل وهو صحيح مقيم
No references are available.
Bukhari narrated it in the Book of Jihad and Expeditions, chapter, "The traveler is credited with the same reward as he used to earn while at home," hadith no. 2996, from the hadith of Awwam bin Hawshab with this wording.