Before Buddhism, was there a way to escape from samsara? Before the Buddha introduced nirvana and enlightenment, was there any way to escape from the cycle of birth and death? What is written in Buddhist texts?
Some Buddhist texts say that there were previous Buddhas (and that there will be others in the distant future): that they too taught Buddhism; and that the current Buddha rediscovered Buddhism.

For example, in the commentary to Dhammapada verse 183:


  On one occasion, Thera Ananda asked the Buddha whether the Fundamental Instructions to bhikkhus given by the preceding Buddhas were the same as those of the Buddha himself. To him the Buddha replied that the instructions given by all the Buddhas are as given in the following verses:
  
  Then the Buddha spoke in verse as follows:
  
  
    
    Not to do evil, to cultivate merit, to purify one's mind - this is the Teaching of the Buddhas.
    The best moral practice is patience and forbearance; "Nibbana is Supreme", said the Buddhas. A bhikkhu does not harm others; one who harms others is not a bhikkhu.
    Not to revile, not to do any harm, to practise restraint according to the Fundamental Instructions for the bhikkhus, to be moderate in taking food, to dwell in a secluded place, to devote oneself to higher concentration - this is the Teaching of the Buddhas.
    
  


There are even some suttas, such as SN 12.65 which implies that Nirvana and the path the Nirvana was "inhabited in ancient times" and rediscovered by the Buddha.


  In the Nagara Sutta, the delightful ancient fortress city [§20.2] clearly refers to nirvana, and the city is
  populated by saints (called “seers,” rsi, in the Sanskrit Nagara Sutra, §5.28). Both the Pali and Sanskrit
  versions of the Sutta speak of ancient people using the path.


Texts also say that a few people (called "private Buddhas") discover Nirvana for themselves, but (unlike a true Buddha) aren't able or aren't willing to teach other people.