title: How do I programmatically retrieve previous versions of master pages from a SharePoint site?
body: <p>In a SharePoint site, as you checkout/modify/checkin a master page, previous versions of the master page are retained in SharePoint and you can see a <em>list</em> of previous versions in the master page gallery. It seems to me that the only way to view the <em>contents</em> of a previous version, is to do a restore of that version - this however will create an additional entry in the version history, which isn't really a new version but simply an artefact of <em>viewing</em> a previous version.</p>
  
  <p>I eventually found a rather brute force method of viewing previous versions by using the <code>stsadm</code> utility:</p>
  
  <pre><code>stsadm -o export -url http://site -fileneme export.cab -versions 4
  </code></pre>
  
  <p>then looking in the <code>manifest.xml</code> file in the cab to then find a pointer to the relevant <code>.dat</code> file in the cab to view the required previous version. Now this 'solution' is obviously problematic for large sites, as the export operation exports the entire site content.</p>
  
  <p>So here's my question ... If <code>stsadm -o export</code> can extract previous versions of files, I'm guessing that there is some way to do this programmatically through the SharePoint API. Does anybody know if/how this is possible.</p>