0

I have requirement which is when user accidentally select delete button for site collection it has to perform backup operation automatically before it deleted is there any WSP solutions available please suggest me.

Many Thanks

1
  • 1
    How long do you need to keep that backup available? Sep 13, 2018 at 10:44

1 Answer 1

2

I think no need for WSP solutions, the SharePoint already handles this operation by adding the deleted site collection in the Second stage when a user accidentally deletes a site collection from GUI Central Admin.


How to Restore Deleted the Site Collection

If you've accidentally deleted a site collection, you can restore it back within 30 days depends on the Site Quota using Restore-SPDeletedSite PowerShell.

Check also Delete and restore site collections in SharePoint Server


But if you need to keep the backup for a long time (> 30 days), you can handle this through the code, by developing your own Event Receiver to perform a backup when a site collection is being deleted

enter image description here

Now, you just need to know How to perform a backup to a site collection

Backup Site collection C# Code

SPFarm myFarm = SPFarm.Local;
SPServiceCollection myServices = myFarm.Services;
Guid serviceID = new Guid("21d91b29-5c5b-4893-9264-4e9c758618b4");
SPWebService webPubService = (SPWebService)myServices[serviceID];

// Get a reference to the Web application that hosts the 
// site collection.
SPWebApplicationCollection myApps = webPubService.WebApplications;
Guid appID = new Guid("10ea4e6f-ae37-4909-b04f-f516c066bc37");
SPWebApplication myApp = myApps[appID];

// As alternative to the preceding three lines, you can use
// the following when you know the URL of the Web application:
//     SPWebApplication myApp = SPWebApplication.Lookup(url_of_Web_app)

// Get a reference to the Web application's collection of 
// site collections. 
SPSiteCollection mySiteCols = myApp.Sites;

// Back up a specified site collection. 
mySiteCols.Backup(@"http://Server/sites/MySiteCollection", @"\\OtherServer\WSSBackups\SiteCollections\BackupOfMySiteCollection", true);

Check also How to: Programmatically Back Up and Restore a Single Site Collection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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