in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

in·for·ma·tion /ˌɪnfərˈmeɪʃən/ [in-fer-mey-shuhn]

"Knowledge is of two kinds. We know a subject ourselves, or we know where we can find information on it." -- Dr. Samuel Johnson [1709 - 1784]

"Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?" -- T. S. Eliot [1888 - 1965]

How to delete historical document versions in WSS 3 / MOSS?? ....not entirely simple...

So here's another tricky issue (and another missing feature) in the MOSS/WSS 3 landscape.

What happens when you encounter a document library (or many libraries) with hundreds of documents with multiple versions? - maybe even 50+ versions per document because someone forgot to consider version trimming during the planning or failed to educate the end users on the implications of versioning.
If a library is created with versioning enabled, the library settings show major versions enabled but with NO default setting for trimming, but the user doesn't get to see this unless they actively go into the library settings after creation. This relies on the user actually knowing how to manage versions in MOSS - this can never be guaranteed.

Of course, each one of these versions will be taking up valuable space in the database and having an impact, not only on the current db size, but the time and size of the daily SQL backups.

Is there a way to purge old versions in MOSS/WSS 3 without affecting the latest/current version??

Sadly (and almost predictably) there is NO default function for post-trimming / deleting document versions en masse, either in a single library or accross a site collection. With 100's or 1000's of documents across a site collection it would be no mean task to manually trim them all.

So far, in search for an answer to this, we came across the following third-party tool for SPS2003 (http://www.sharepoint247.com/FreeTools/DeleteVersions/tabid/56/Default.aspx), unfortunately it appears not to have been updated for MOSS/WSS 3.

However, there is a small light at the end of this tunnel - I suspect more by chance than design...

If you change the settings for an existing document library to trim the number of versions to, for example, no more than 3 major versions (Document Library Settings > Versioning Settings > Document Version History > Optionally limit the number of versions to retain), then when a user modifies or uploads a new version of a document, all but the latest specified number of versions will be deleted.

In our particular client case, this workaround was perfect since all the documents (application & network performance reports) are batch copied to a single library on a nightly basis. Simply reseting the library versioning & running the batch again forced the database to trim all the versions to 1 per document. After that it was a simple SQL process to shrink the database.

However, this still leaves a couple of mighty big holes in the document management feature set for in MOSS / WSS 3 :-

  • NO default version trimming set at creation time.
  • NO means of post trimming versions across site collections, sites or multiple libraries beyond manually deleting every unwanted version on every individual document.

What happens in an enterprise portal with 1000's of document libraries that can't be batch copied and replaced??? Scary eh...
With such a complex product as SharePoint you'd think the development team would have seen some of these glaringly obvious shortcomings (and yes, I have a list...)

So, mental note to self (and anyone else who's paying attention)...

  • Plan carefully for versioning management...
  • Educate clients on the implications of versioning...
  • Educate clients on the need to educate their end users...
  • Buy shares in storage hardware companies ;)

 

Published Apr 01 2008, 05:58 PM by agoodwin
Filed under: , ,

Comments

 

Links (4/1/2008) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (4/1/2008) « Steve Pietrek’s SharePoint Stuff

April 1, 2008 8:06 PM
 

??ghyBlog » links for 2008-04-02 said:

Pingback from  ??ghyBlog » links for 2008-04-02

April 2, 2008 5:33 PM
 

Bookmarking the web - w14/2008 - double density design said:

Pingback from  Bookmarking the web - w14/2008 - double density design

April 6, 2008 7:08 AM
 

SharePoint 2007 Link Love: 03-06-2008 at Virtual Generations said:

Pingback from  SharePoint 2007 Link Love: 03-06-2008 at  Virtual Generations

April 6, 2008 9:02 AM
 

John Kackley said:

Right now I'll settle for a manual way of deleting every version.  How do I do that?

April 8, 2008 12:11 PM
 

agoodwin said:

Hi John,

It's simple, if a little long-winded (especially if you have many documents and many libraries). Here's how:

- Browse to the library and locate the document you wish to manage versions of.

- Use the drop-menu from the document and select 'version history'

- From this version history page you can use the drop menu from the date reference to delete individual versions

- From the toolbar menu on this page you can delete all versions (except the most current),

- Or if both minor & major versions are enabled, there is an option to delete all the minor versions

PS - this assumes you have sufficient permissions in the site/library/document to be able to do this.

April 8, 2008 12:55 PM
 

agoodwin said:

As an appendix to this, I had some feedback from a microsoft support engineer when I raised this as part of an open support issue.

He suggested a couple of solutions using code to remove versions from the database.

Note: neither of these are supported by MS - and I've not tested either of them...yet.

1.

===

SPWeb web = SPControl.GetContextWeb(Context);

SPFile file = web.GetFile(txtFilePath.Text); if (null != file) { int iBefore = file.UIVersion;

SPFileEx fileEx = new SPFileEx(file);

fileEx.Title = txtTitle.Text;

fileEx.Update();

// Re-fetch the file obj

SPFile fileNew = web.GetFile(file.ServerRelativeUrl);

int iAfter = fileNew.UIVersion;

if (iAfter > iBefore)

{

//Delete the newly generated history version fileNew.Versions.DeleteByID(iBefore);

}

}

2.

==

SPSite site = new SPSite("http://localhost:888");

           SPWeb web = site.OpenWeb();

           SPFolder myFolder = web.Folders["Shared Documents"];

           foreach (SPFile myFile in myFolder.Files )

           {

               myFile.Versions.DeleteAll();

           }

-------

So the basic components are 'SPFile' and 'Versions.DeleteAll'

There's also a newsgroup thread around this issue: wss.collutions.com/.../DispForm.aspx

April 9, 2008 3:46 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts