It is narrated from Sayyiduna Abdullah bin Abbas (may Allah be pleased with him) that when the Messenger of Allah (peace and blessings be upon him) besieged the people of Ta’if, two slaves from among them joined the Messenger of Allah (peace and blessings be upon him). One of them was named Abu Bakrah. The Messenger of Allah (peace and blessings be upon him) set both of them free. It was the blessed habit of the Messenger of Allah (peace and blessings be upon him) that whenever a slave from the enemy’s side joined him, he would set him free.
Hadith Referenceالفتح الربانی / أهم أحداث السنة الثامنة للهجرة / 10913
Benefits: … The reason for the kunyah of Sayyiduna Abu Bakrah radi Allahu anhu is that he climbed down from the wall of a fort by hanging onto a pulley, which is used to draw water from a well, and in Arabic, a pulley is called "bakrah." Therefore, the Messenger of Allah sallallahu alayhi wa sallam gave him the kunyah Abu Bakrah.