Deleting a partially restored site collection

Hi Everyone, I am here to explain one real time scenario which I faced recently in my organization.
 
Scenario
  1. Need to take a site collection backup from pre-production environment (UAT) using GUI(central administration)
  2. That backup item should restore in Production environment
Steps followed
  • login the central administration in app server from pre-production environment (UAT)
  •  Select the Backup & restore
  • chosen an option take a Site collection Backup from Granular backup
  • then stored the backup in DFS (Data File Storage server)
  • then I log in the production environment and tried to restore the backup item using management powershell console
  • I used the following powershell cmdlets "Restore-SPSite http://Server_name/Sites/Site_name -Path D:\Backup\site_name.bak"
  • after twenty minutes powershell console closed suddenly without any message, then checked the site collection URL getting 403 forbidden error.
  • then again tried to restore the site collection backup
  • then it shows site collection already exists
  • then I tried the "Restore-SPSite http://Server_name/Sites/Site_name -Path D:\Backup\site_name.bak - Force" to overwrite. But it shows the same error
  • Then I checked the site collection properties using Get-SPSite but it shows property not found.
  • then I followed the below script to delete the site collection from content database
  1. $site = Get-SPSite https://server_name/sites/site_name  
  2. $siteId = $site.Id  
  3. $siteDatabase = $site.ContentDatabase  
  4. $siteDatabase.ForceDeleteSite ($siteId, $false, $false)  
  • then check the site collection properties using Get-SPSite, you can see the site collection deleted from content database
  • then started restore again the site collection.
This time finished successfully ! I hope this may help you for your reference.