As per Qur'an or Sunnah, once the good deeds are erased, can they ever be brought back? Or are they lost forever? I know it is entirely Allah(SWT)'s will, to return them or not. But, I want to know if any evidence exists that a certain deed or action can return the lost good deeds.
In the name of God, the Gracious, the Merciful. Praise be to God, and prayers and peace be upon the Messenger of Allah and his family and companions, Having said that,
Peace be upon those who follow guidance
God Almighty said :
("Except for those who repent, and believe, and act righteously. These will enter Paradise, and will not be wronged in the least")(Surat Maryam:60)
("God does not forgive association with Him, but He forgives anything less than that to whomever He wills. Whoever associates anything with God has devised a monstrous sin")(Surat an-Nisa':48)(association means shirk)
("Say, “O My servants who have transgressed against themselves: do not despair of God’s mercy, for God forgives all sins. He is indeed the Forgiver, the Clement")(Surat az-Zumar:53)(My servants establishes the concept that men are the servants of Allah alone, and its whole message revolves around the point that they should serve none but One Allah alone. The Holy Prophet (upon whom be Allah's peace) himself was Allah's servant. Allah had sent him not as rabb (sustainer, providence) but as a Messenger so that he should himself serve Him and teach the other people also to serve Him alone)(serving God (Allah in arabic) means worshiping him only, that includes doing good deeds and having good manners but all these good deeds are worth nothing if one has worshiped other than God)
("Say to those who disbelieve: if they desist, their past will be forgiven. But if they persist—the practice of the ancients has been going")(Surat Al-Anfal:38)(the ancients practice: Which they have sinned and denied God's messengers, and so they were tormented)
Prophet Muhammad -prayers and peace of Allah be upon him- said : "The Almighty God extends his hand at night to repent sinner of the day, and extends his hand during the day to repent sinner of the night until the sun rises from its sunset" (sun rising from its sunset is a metaphor of Judgment Day)
Prophet Muhammad -prayers and peace of Allah be upon him- also said : "Allah accepts the repentance of a servant unless he is dying"
your question is focused mainly on repenting, from the Koran we know that one of the names of Almighty God (Allah -in Arabic-) is The Repentant, and the repentant is the one who accepts the repentance of his servants (worshipers) changing their paths from dark to light, any worshiper who has disobeyed and reached his extent of disobedience and then wanted to repent to God only, God will open the doors of his mercy, and rejoicing in his worshiper return and repentance, unless he died before that or the sun rises from the its sunset. but if someone has gone into the path of polytheism, infidelity or even atheism (shirk or kufr) that means his belief in God was weak or fake because if the belief was strong and real he wouldn't go this way after believing and knowing the truth.Therefore the repenting require the will to not go back to such great and dangerous sins.
and God knows everything,