For shutting down on power failure u definitely need UPS.
As far as restarting when power comes back, it depends on your BIOS check if it has option to Switch on on power resume.
Do u have UPS, if positive u can configure it from Power Options in Control Panel to suite your needs !!