How to Synchronise phases of main and ups?
If your microcontroller would reboot at an 8 ms brown-out of the mains power, then it means your power supply is underdimensioned. Increase your smoothing electrolytic capacitors.
Like Dave says phase is not important. If you switch fast from the mains to a UPS power supply which is 90° out of phase the transformer will have a very small hick-up, but the high inductance will make sure there won't be sudden changes in current.