Coup against the then Ukrainian President who is probably from Donbas was part of the root causes of Russia intervention in the regions and Ukraine, rather than so called rare earth metals. Crimea decided to become part of Russia through democratic means, a referendum, after the coup. And Donbas was subsequently invaded by Ukraine, and then began a war between Donbas and Ukraine before Russia finally intervened in 2022 to protect donbass and others. Had Russia provoked the coup and the war against Donbas, the whole thing would look suspicious. But it wasn't provoked by Russia which means Russia likely never anticipated having Donbas and others under her protection in order to mine rare metals. It was coup which was done for the purpose of full capture of Ukraine by pro western forces.
I agree with you that the goals of Russia invading Ukraine wasn't mainly for rare earth metals, but this reason became essential later in negotation file with USA and Europe. Russia first goal is to forbid NATO from setting power army in its frontieres after Ukraine showed its ambitions to join the military ally with NATO. Putin decided to invade Cremea before invading all other regions to create like a safe armyless land between the two countries. Usually there is no single reason to start a war.