Power has been restored to most of the 130,000 homes and businesses affected by a massive outage in San Francisco.