Literally 'lose sheep, mend pen.' From a story in 战国策 (Zhànguó Cè, Strategies of the Warring States): a shepherd lost sheep because his pen was broken, but his neighbor said it wasn't too late to repair it.
Mending the pen after losing a sheep is still better than doing nothing.
Tips
usage
This idiom is almost always followed by 为时未晚 (wéishí wèi wǎn, 'it's not too late') or 犹未迟也 (yóu wèi chí yě, classical version of 'still not late'). It's the Chinese equivalent of 'better late than never.'