Presumably, those years were indeed accumulated during the Siege of Trenzalore as you say. There were two massive time gaps in that episode; the first spanning 300 years and the second spanning an unspecified-but-certainly-very-long period of time. The tie-in novel "Tales of Trenzalore" states that he spent a total of 900 years on the planet, but as that story also depicts him with a missing leg (a development that was cut from the original script for "The Time of the Doctor"), the relevance of that book is debatable.
However, the prevailing truth is that, after "Time and the Rani" (in which he had to be 953, as he used the fact that he and the Rani are the same age in order to deduce that her age-based password was that number) at the earliest, the Doctor has simply lost track of what age he is. He states as much in "The Day of the Doctor", and if, for example, we were to factor in the alleged 600 years that the Eighth Doctor spent on the titular planet in the Big Finish audio drama "Orbis" (although even in that story, he states that he doesn't always count years the same way and that he sometimes adjusts his age count based on wherever in the universe he is in at any given time), then that would already make him over 1,000 by the time of his Eighth incarnation, which thoroughly contradicts his Ninth incarnation's assertion of being 900 years old (although "Time and the Rani" already accomplished that thanks to the aforementioned 953 figure), rendering any age that any post-Time War Doctor gives to be of questionable accuracy. So while Twelve may claim to be over 2,000 years old, all that we can say with certainty is that he is very, very old.