Recover a SharePoint Online Site

In SharePoint Online, it’s easy to delete an entire site or documents in a site.

Recovering documents is also quite easy, go to the site’s recycle bin which is normally located at – replacing ‘contoso’ with your tenant name, and ‘sitename’ with the actual site name. Deleted items can be selected and restored to their original location.

How long are deleted items kept in the Recycle Bin?

In SharePoint Online, the default retention time is 93 days for both site recycle bin (first stage) and site collection recycle bin (second stage). The site recycle bin storage counts against your site collection storage quota and the List View Threshold. The site collection recycle bin retention starts at the same time for both recycle bins when the item is first deleted, so the total maximum retention time is 93 days for both recycle bins. The default amount of space for the site collection is 200% of the site collection quota.”

However, I had some issues when trying to recover an entire site. My top level recycle bin showed nothing. I’m unsure if there’s another way of viewing deleted sites via the web interface, and gave up after a lot of clicking around and Googling, but it’s easy to do with PowerShell.

After installing the SharePoint Online Management Shell, and connecting to SharePoint Online with the ‘Connect-SPOService‘ cmdlet (and don’t forget to use HTTPS rather than HTTP when connecting to your SharePoint Online instance or you’ll get a rather generic error: connect-sposervice : Could not authenticate to SharePoint Online using OAuth 2.0), you can see what your deleted sites are with this command:


Simple, you’ll then be presented with a list of all sites that are deleted and waiting in the recycle bin along with when they were deleted, and how many days are remaining before they disappear from the recycle bin. Sites deleted seem to sit in that recycle bin for 30 days, rather than site collection items but I couldn’t find any documentation supporting this.

To restore a deleted site, just use the following command with the URL of the site to restore, which you can see from the ‘get’ command above

Restore-SPODeletedSite -identity

That’s it. Your site is back.

From what I’ve read, there is no way to change the retention values of SharePoint Online recycle bins.

6 thoughts on “Recover a SharePoint Online Site

  1. Maybe it wasn’t the case at the moment the article was written but at the bottom of the page you have a link to the secondary recycle bin (“Corbeille secondaire” in french). You could be able to find your items here I think.

    1. You’re exactly right Flav :) I’ll update the article in the next few days to reflect that, thank you!

  2. Adam – I’ve struggled to find the PowerShell for SharePoint online (Office 365) to automate restoring files from the recycle bin which is very necessary for situations the GUI cannot handle. We’ve just been in a situation where a user somehow deleted 60,000 files in 7700 folders from a Teams channel in attempting to remove a synced channel in the file explorer. I started using the GUI and was even able to scroll down and select 20,000 items at one point (this took a while!) but was greeted by various error messages or the SharePoint webpage just crashed. In these scenarios it leaves you at the whim of Microsoft support. I’ve been able to do various PowerShell queries (retrieve a list of the files in recycle bin by user for example) but not automate a restore of all files in a recycle bin deleted by a specific user. I know I’m not the only one who has found themselves in this situation so a PowerShell solution we can implement ourselves would be priceless!

      1. Hi Adam and thanks for the reply. I found that script before I came here but have not been able to get it to work – I’ll keep trying as it would be good to have in the armoury ;-) The good news is that Microsoft have just done the recovery for me and we have our files back – but the whole process of raising the ticket in O365 admin center and eventually getting to the back end team who did the job was not as straightforward as it could have been and it never felt like there were any guarantees from the first line support at all (surely they must be familiar with the scenario by now?).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.