We have created a trigger that generates some information for a column on the Opportunity object. We now want all 400,000 existing opportunities to have the same information. The logic is encapsulated into a class, and is fairly complicated so ideally I'd like to run the same logic inside salesforce so I can be sure the rules are applied to historical data exactly the same as they would be with the trigger.
I tried using a batch apex class that inherits from Database.Batchable but I found that some of my records weren't being updated and it's been very difficult to figure out why because different records get ignored each time. When I ran the batch process for individual records, they seem to update fine. Running the process again for the whole batch updated some more but not all. I can't run the process more than once in live because it has to finish overnight and I want to be sure everything has been updated.
Is a batch apex class the best way to do this or are there other options?