The Russian guards at the country’s border with Estonia had questions for Katya Aksenko and her aging parents when they arrived there at the end of April. Did they have relatives in the Ukrainian army? Or the police? Or the government?

In the previous several weeks, the members of the Aksenko family had fled a bomb shelter near their home in the southern Ukrainian city of Mariupol, passed through a Russian filtration camp and embarked on a roughly 1,000-mile journey through Russian-held Ukrainian territory and Russia itself.

Now the Aksenkos were at the edge of Europe. Just a few feet ahead was Estonia and, beyond that, a haven with family in the mountains of western Ukraine.

They said they knew no one in the military. The soldiers let them through.

A rocket fired by a Russian tank hit an apartment building in Mariupol in eastern Ukraine, in March. Russia took control of the city in May.

Photo: Evgeniy Maloletka/Associated Press

Ukrainian police and military checked the documents of people leaving Mariupol at an evacuation point in Zaporizhzhia, Ukraine, in April.

Photo: roman pilipey/Shutterstock

The Aksenkos are part of a growing exodus of Ukrainians from the country’s east, whose only escape route from the conflict is through Russia. More than 32,000 Ukrainians have entered Estonia from Russia since the war began in February, up 14,000 from the same period a year earlier, according to government figures.

Not everyone who sets out from eastern Ukraine makes it safely to Europe.

To reach the Estonian border, the Aksenkos navigated the rubble of Mariupol during breaks in the shelling. They found a network of drivers ferrying Ukrainians through Russia. For much of the journey they were afraid to use their phones or even speak, worried anything they said could land them in jail or worse.

“Since leaving Mariupol, I felt like a clenched fist,” Ms. Aksenko said.

On March 1, as bombs rained down on Mariupol, Ms. Aksenko texted her cousin in Toronto, Anastassia Vitkovitsky. “Today they bombed nearby on our street,” she wrote, before saying the family was going to try to get some sleep. “Kisses, my dear.”

It was the last message she sent.

Ms. Vitkovitsky spent the next two months trying to find out if Ms. Aksenko and her parents were safe. Ms. Aksenko and her 61-year-old mother and 65-year-old father, meanwhile, were holed up in a basement shelter unable to contact her.

The conditions were dire: 150 people, including dozens of children, were crammed into the shelter’s three rooms. They shared one bathroom and had to sleep in turns because there wasn’t enough room for everyone to lie down.

The lights cut out, then the water. During lulls in the bombing, Ms. Aksenko’s parents ran home to get canned food to cook on the stove outside or water to flush the toilet. Each time they went out, more of the neighborhood had been destroyed. When the toothpaste ran out, they chewed cloves, which one of the shelter’s other residents said was good for warding off infection.

One day in late March, 18 shells hit the shelter. Another day, a bomb fell nearby while a few people were outside cooking. One neighbor staggered back inside with gashes on his neck and elbow. Ms. Aksenko, a pharmacist, wrapped his elbow in a dog mat, then sewed his neck shut with a needle and thread, using a cigarette lighter as a thimble to help push the dull needle through his skin.

As Russian forces advanced into Mariupol, more people in the shelter began to leave. Some returned, unable to get out of the neighborhood as fighting raged. In other cases, word trickled back that neighbors had made it.

In late April, Ms. Aksenko said she had a dream that the family left Mariupol, along with another man who was in the bomb shelter with them. When she woke, that man told her he was leaving. Ms. Aksenko told her parents they had to go with him. “I just had a feeling that we need to go today,” Ms. Aksenko said.

Pushing a wheelbarrow full of belongings, they left the shelter and began a laborious, two-hour trek toward the Sea of Azov and then along the coast to a checkpoint manned by pro-Russian separatists.

Katya Aksenko and her father in their new home.

Photo: Emanuele Satolli for The Wall Street Journal

Over the next two days, the family was taken by bus first to one village on the outskirts of Mariupol, then another, where soldiers had set up a filtration camp—a processing point that Russian forces use to check Ukrainian civilians and weed out anyone they suspect of helping the military.

Soldiers inspected the Aksenkos’ documents, searched their bags and took their fingerprints. Because her father was older, Ms. Aksenko said, he was spared a strip search for tattoos that might show any affiliation with the Ukrainian military.

Before setting off from the shelter, the family had deleted apps and messages from their phones that they thought could betray pro-Ukrainian sentiment.

After the inspections, the Aksenkos were handed papers that allowed them to travel onward—but not back into Ukraine. Their options were Russian-held territory or Russia itself.

The family managed to get on a bus to Donetsk, a regional capital in eastern Ukraine that is under Russian control. When they reached the city, Ms. Aksenko said, she began to cry.

When she had studied there, before the first Russian invasion in 2014, the city was known for its roses. There were no more roses, said Ms. Aksenko, and the buses looked like they were from the 1940s. She said she was afraid of the pro-Russian Ukrainians running the city.

The Aksenkos went to the apartment of an acquaintance who had fled to Poland early in the war. There was no running water in the city, so they took turns using bowls to pour water over themselves in a tub, the closest thing they had had to a shower since early March.

“Miners were cleaner than we were,” Ms. Aksenko said.

Next door was a separatist military outpost and pro-Russian soldiers were coming and going all day. The Aksenkos didn’t feel comfortable speaking, even to each other. They decided they had to leave.

A friend told them about some men from eastern Ukraine who had fled to Russia instead of fighting for the pro-Russian forces. They were ferrying Ukrainians through Russia and into Europe. The Aksenkos devised a plan: they would rendezvous with Ms. Vitkovitsky’s father—Ms. Aksenko’s uncle—who had returned home to western Ukraine to help with the war effort.

SHARE YOUR THOUGHTS

What will be the long-term impact of the war on civilians? Join the conversation below.

To get out, however, they needed rubles, the Russian currency. They had none.

At the bus station, by coincidence, Ms. Aksenko spotted a man she recognized from the bomb shelter. His wife had died and a bomb had destroyed his apartment. He pressed rubles into her hand.

Crossing the border into Russia, a man from Mariupol traveling with them was detained for hours. The Aksenkos were let across, and boarded an eight-person bus headed for Estonia. During the 24-hour trip, virtually nobody spoke.

As they approached the Estonian border, the Aksenkos said they grew increasingly nervous. They checked their phones once more in case they had forgotten to delete anything. “We didn’t feel safe,” Ms. Aksenko said. “We were just silent.”

At the border, Russian soldiers quickly separated the men from the women.

The Aksenkos knew that not everyone is allowed out of Russia. About 10% of Ukrainians trying to leave Russia for the European Union are stopped, according to Svetlana Alekseevna Gannushkina, head of the Civic Assistance Committee, a Russian civil-rights group.

The reasons why—and what happens to them after—are not always clear. “There are no obvious rules,” Ms. Gannushkina said. She said some “people disappear without a trace after they enter Russia.”

A young woman traveling with the Aksenkos was questioned about her ex-husband, who worked in the Ukrainian civil service. Looking at Ms. Aksenko’s elderly parents, the border guards waved the family through.

On the Estonian side of the border, everything suddenly felt different. The bus terminal they walked to was warm. The bathrooms were clean.

Another 24-hour bus ride took them through Estonia and into Latvia, through Lithuania and Poland to the Ukrainian border. Ms. Vitkovitsky’s father, Vassyl Vitkovitsky, picked them up at a gas station just inside Ukrainian territory.

Katya Aksenko in the garden of her new house, where the family grows herbs and vegetables.

Photo: Emanuele Satolli for The Wall Street Journal

For the past two months, Ms. Aksenko and her parents have been living in a quiet village in western Ukraine. She is looking for work as a pharmacist. She is also applying for a visa to visit her family in Canada. Her mother, Natasha, works in the garden, growing parsley, dill, onions and carrots.

Often, Natasha Aksenko said, she dreams of her home in Mariupol, where the family lived for decades and she grew fruit trees in the courtyard outside. She realizes she may never see it again.

“We’re comfortable here. The people are friendly,” she said. “But it doesn’t feel like home.”

Write to Ian Lovett at ian.lovett@wsj.com and Dan Frosch at dan.frosch@wsj.com