{"id":1920,"date":"2012-04-04T05:58:19","date_gmt":"2012-04-04T05:58:19","guid":{"rendered":"https:\/\/poiseddevelopers.com\/reality-tech\/?p=1920"},"modified":"2024-04-12T07:19:59","modified_gmt":"2024-04-12T07:19:59","slug":"gradual-site-collection-deletion","status":"publish","type":"post","link":"https:\/\/poiseddevelopers.com\/reality-tech\/gradual-site-collection-deletion\/","title":{"rendered":"Gradual Site Collection Deletion"},"content":{"rendered":"<h4>Gradual Site Collection Deletion<\/h4>\n<p>I had a mission to achieve overnight; move 28 site collections into a new managed path, as well as rename the 28 associated content databases.\u00a0\u00a0 Pretty straightforward to do, and to script in advance to run in stages:<\/p>\n<ol>\n<li>Backup site collections<\/li>\n<li>Delete site collections<\/li>\n<li>Dismount content databases<\/li>\n<li>Rename content databases and shuffle around underlying storage including FILESTREAM RBS location<\/li>\n<li>Create the new managed path; reset of IIS<\/li>\n<li>Remount 28 content DBs<\/li>\n<li>Delete the old managed path<\/li>\n<li>Restore the 27 content databases (this is where tinkling glass is heard, followed by painful silence)<\/li>\n<\/ol>\n<p>After enough jolt cola to get that turtle to beat the hare fair and square, I got to the bottom of the problem.\u00a0 First the problem.\u00a0 The site collections could not be restored into their original database, as the site collection purportedly already existed there.\u00a0 Even though it was deleted.<\/p>\n<p>By midnight I gave up, and did the 28 Restore-SPSite into any random content databases, tossing organization and structure to the winds (temporarily), knowing I\u2019ve got gads of available storage, knowing once I got to the bottom of the issue, a simple set of move-spsite commands would set things right.\u00a0 No, I don\u2019t like randomness, but I also like a few winks of sleep and happy users\u2026<\/p>\n<p>Now the cause.\u00a0 I\u2019m running SharePoint 2010 SP1, which has the ability to recover deleted site collections (not through the UI, but only through PowerShell).\u00a0 I used the -gradualdelete option, thinking I would be nice and gentle with a production farm.\u00a0 Here\u2019s a sample of my delete commands, where I also disable prompting:<\/p>\n<pre lang=\"php\"> Remove-spsite&amp;amp;nbsp; href=\"http :\/\/SharePoint\/div\/clm\/int\/A\/\" &amp;amp;nbsp;-confirm:$false -gradualdelete\r\n<\/pre>\n<p>Here\u2019s the kicker.\u00a0 After the delete, the site collection is indeed still there.\u00a0\u00a0 It sticks around actually for the duration of the the Recycle Bin duration (default 30 days).\u00a0 There\u2019s one good way to see, let\u2019s dive into the forbidden content database, and have a peek:<\/p>\n<pre lang=\"php\"> SELECT [DeletionTime]\r\n,[Id]\r\n,[SiteId]\r\n,[InDeletion]\r\n,[Restorable]\r\nFROM [Content_mydivision_a].[dbo].[SiteDeletion]\r\nwhere (Restorable=1)<\/pre>\n<p>Restorable=1 indicates this site collection could be restored.<\/p>\n<p>The solution?\u00a0 Well, it\u2019s not the recycle bin job, that has no effect on this.\u00a0 There is a gradual delete job at the web application level, but that won\u2019t help us either; at least not just yet.\u00a0 First you have to use the remove-spsite CmdLet to remove each site permanently.\u00a0 Here\u2019s the syntax:<\/p>\n<pre lang=\"php\">remove-spdeletedsite f5f7639d-536f-4f76-8f94-57834d177a99 -confirm:$false\r\n<\/pre>\n<p>Ah, you don\u2019t know your Site Collection GUIDs by heart? well, me neither, I prefer more useful allocation of brain cells, so here\u2019s the command that will give you the Site Collection GUIDs that have been (partially) deleted:<\/p>\n<pre lang=\"php\">  get-spdeletedsite -webapplication \"http :\/\/SharePoint\/\"\r\n<\/pre>\n<p>So, you got your partially deleted GUIDs, you diligently did a remove-spdeletedsite for each, but the Restore-SPSite still will not work.\u00a0 Now\u2019s the time to run the handy-dandy Gradual Delete timer job for your web application, in Central Admin, Monitoring.\u00a0 First thing you might notice is the job is taking a bit of time to run.\u00a0 That\u2019s good, it\u2019s doing something for you, and actually triggering the Content DB Stored Procedure called proc_DeleteSiteCoreAsync.\u00a0 It actually deletes in batches.<\/p>\n<p>Here\u2019s how to wipe out all these mildly annoying site collections from your recycle bin for a web application:<\/p>\n<pre lang=\"php\">  get-spdeletedsite -webapplication \"http:\/\/ma-srv-sp10\/\" | Remove-SPDeletedSite\r\n<\/pre>\n<p>At this point your Restore-SPSite will work to your target content database, and if you played SharePoint Roulette like me and restored to a random location, a move-SPSite will make fast work of putting things where they should be.<\/p>\n<p>More information on the Gradual Deletion Timer Job can be found in\u00a0<a href=\"http:\/\/www.avepoint.com\/products\/SharePoint-infrastructure-management\/SharePoint-migration\/\" target=\"_blank\" rel=\"noopener\" aria-label=\"this Technet Article by Bill Baer - open in a new tab\" data-uw-rm-ext-link=\"\" style=\"color:#1f6799\">this Technet Article by Bill Baer<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Gradual Site Collection Deletion I had a mission to achieve overnight; move 28 site collections into a new managed path, as well as rename the 28 associated content databases.\u00a0\u00a0 Pretty straightforward to do, and to script in advance to run in stages: Backup site collections Delete site collections Dismount content databases Rename content databases and [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1931,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[26],"tags":[],"class_list":["post-1920","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"_links":{"self":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/comments?post=1920"}],"version-history":[{"count":2,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1920\/revisions"}],"predecessor-version":[{"id":3010,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/posts\/1920\/revisions\/3010"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media\/1931"}],"wp:attachment":[{"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/media?parent=1920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/categories?post=1920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/poiseddevelopers.com\/reality-tech\/wp-json\/wp\/v2\/tags?post=1920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}