* Rebels turn tide of fighting, advance near Mariupol
* City strengthens defences in case of full assault
* Russia denies it has sent arms, troops to Ukraine
By Aleksandar Vasovic
MARIUPOL, Ukraine, Sept 4 (Reuters) - In the backyard of a former school, masked volunteers snap to attention to mark the creation of a new fighting unit in the port city of Mariupol in southeastern Ukraine.
The ragtag battalion was hurriedly put together from a group of civilians including a piano teacher, bulldozer operator, steel worker and bodybuilding instructor as pro-Russian rebels advanced on Mariupol over the past week.
Renewed shelling of the city on Thursday, despite hopes that a ceasefire might be agreed on Friday, meant Ukrainian troops continued to organise defences in case of an all-out assault by pro-Russian separatists Kiev says are backed by Moscow.
"From now on we are called the Mariupol battalion, and we will be waging a guerrilla warfare behind enemy lines," said their commander, a masked man in civilian clothes who only identified himself as Ilan.
About 30 recruits, some in uniform and others in civilian clothes, formed a line to start training in how to handle assault rifles, while others dismantled unloaded weapons.
"You have to do it automatically, no hesitation," barked an instructor from the Azov battalion, which has already been in battle against the rebels, who were forced out of Mariupol in May.
Ukrainian troops and rebel forces are separated by a strip of land just 20 km (12 miles) wide outside Mariupol.
Ilan said his troops would also train to fight crime inside the city of half a million and resort to guerrilla warfare only if the rebels overrun Mariupol.
"They are all local boys. We are not irregulars, we are formed as a civilian defence battalion within the framework of the Defence Ministry," Ilan said.
Volunteer groups have fought in many areas of eastern Ukraine since the separatists rose up in April, some of them demanding a complete break from Ukraine following Crimea's annexation by Russia and others ready to settle for just a greater degree of independence from Kiev.
Some of the groups, which include members of far-right movements, have taken part in some of the heaviest fighting and helped turn the tide of the conflict in Kiev's favour after Petro Poroshenko was elected president in May. He lifted the army's morale and performance after a bad start to the campaign.
But the tide turned again last week because of what Kiev and Western governments said was an influx of arms and fighters sent by Russia. Moscow denies the accusations.
The pro-Kiev forces were unable to prevent the rebels making gains as new columns of armoured vehicles were reported moving south and east, encircling Ukrainian troops in various towns.
"I think we have no choice but to brace for defence. If they (the rebels and Russians) come, we will give them a bloody nose," said a volunteer who identified himself as a computer expert with the nom de guerre of Slon (Elephant).
"This is a far cry from the business of running a computer repair shop, but we have to step forward and do something," he said.
Another recruit, a hulking man who uses the name Dima, said he worked in a steel mill.
"I can do more good here than working and going home, hoping someone else will defend me and my family," he said. "I have a daughter and I feel responsible for defending her."
Several explosions rocked an area just to the east of Mariupol on Thursday afternoon, sending black smoke skywards.
Underlining the lingering tensions, a Ukrainian military source said the army was on heightened alert because of rumours the rebels were advancing.
The military setbacks of the past week may have sapped morale again in the Ukrainian army, and Kiev faced protests last week by up to 1,000 people demanding the government send more weapons and reinforcements to Ukrainian troops in the east.
Television channels have also been broadcasting army recruitment adverts portraying the glory of fighting for one's country. About 800 Ukrainian soldiers have been reported killed in the conflict so far and, while supporters of the government in Kiev want peace, they also want victory.
Last week's turnaround was particularly embarrassing for Kiev as it followed a large Independence Day celebration, where armoured vehicles and soldiers paraded through the capital in a show of military might.
In and around Mariupol, the mood is one of defiance.
Ukrainian troops this week were digging in along a new line of defence about 15 km (9 miles) outside the city. Many workers wearing overalls from the Metinvest steel producer, and using heavy machinery including excavators and trucks, helped build the defences.
In the village of Shirokine, troops were entrenched near a lighthouse destroyed in a rebel artillery attack, despite the risk of a new attack.
"These guys have a death wish. They entrenched in a position which is clearly marked on every navigation chart," said a villager who refused to identify himself.
Pro-Kiev forces have mounted roadblocks around Mariupol, as well as digging trenches. Mayor Yuriy Hotlubey said the city would be turned into a fortress.
If Mariupol fell, it would give the rebels access to roads leading north to Donetsk and to the west, to the Zaporhizhia province and to Crimea. (Additinal reporting by Timothy Heritage, Thomas Grove and Alesandra Prentice, Editing by Timothy Heritage and Will Waterman)