Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I would like to create a custom deleteweb.aspx page. The code behind first takes a backup of the site before deleting it.

The Backup() method (http://msdn.microsoft.com/en-us/library/cc264319.aspx) can be used to make a backup of my site but how can I make sure this process is fully completed before I remove the site?

share|improve this question
add comment

2 Answers

If you have installed Service Pack 1, there is now a site recycle bin that basically will allow you to restore a site that was deleted for a specified period of time, almost eliminating the need for this. There are also some third party tools that will automatically do this for you as well.

share|improve this answer
    
Lori thanks for your feedback (Just back from some hollidays, reason for my late reply) Can you trigger the site recycle bin through code? In my solution I only have site collections which need to backed up before deleted and some other details about the site need to be erased from a custom list. This is why I'm looking into a custom approach. –  Wim Hill Sep 29 '11 at 9:34
    
You could feasibly create a site workflow that would delete the information from this list, then perform the delete action. May save you some coding. –  Lori Sep 29 '11 at 13:54
add comment

I would use the event system to do what you are thinking.

Create an eventreceiver overriding the SiteDeleting event and in that code do your backup.

Then create a feature that assigns that eventreceiver to all the webs in your farm and any new webs.

I have some examples of both posted on my blog http://www.thelineberrys.com/default-category/how-to-store-each-sharepoint-site-collection-in-its-own-database---part-3-2.html and http://www.thelineberrys.com/default-category/how-to-store-each-sharepoint-site-collection-in-its-own-database---part-2.html

share|improve this answer
    
Hi Steve, this looks like a good solution but how do I handle the completion of my site backup? So this code is executed before the SiteDeleting event but how does SP know the backup is completed and continues with the actual site deletion? –  Wim Hill Sep 29 '11 at 9:38
    
Your event handler code will need to block until the backup is finished. I'm pretty sure when you call the code to do the backup it should block so I think you'll be fine. –  Steve Lineberry Sep 29 '11 at 12:13
    
I'll try and test this with a big site, thx for the update –  Wim Hill Sep 29 '11 at 12:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.