I am writing a code which does a restore of site collection programatically. I am using Site Deleting Event handler. I need to take backup of individual Site, not the Site Collection. How should i do it?
4 Answers
I don't think SPWeb objects have a Backup method like how Site Collections do, so you may have to somehow call stsadm from within your event handler code.
-
SharePoint doesn't allow you to backup/restore, move, etc. SPWeb objects like you can with an SPSite object. SPWeb objects are completely dependent on the SPSite that they belong to, thus you cannot back them up or restore them independently of the SPSite. May 9, 2012 at 15:45
The SharePoint Site Recycle Bin functionality that is a part of the Microsoft SharePoint Governance and Manageability project on codeplex does something similar to what you want.
The SharePoint Site Recycle Bin is a SharePoint Foundation 2010 solution package that when deployed to a Microsoft SharePoint Foundation 2010 or Microsoft SharePoint Server 2010 server farm enables administrators to create a snapshot of subscriptions, site collections and Webs as they are deleted through the SharePoint user interface, the SharePoint Administration Tool, the SharePoint 2010 Management Shell, SharePoint 2010 Central Administration, or SharePoint Designer.
There is a version for SharePoint 2007 as well.
I believe you can get the equivalent of an stsadm -o export out of the Content Deployment API. Check out the MSDN page.
using SPExportObject will do the job.
-
1