Some time ago, I published an overview of the modern Compliance features available in SharePoint Online and Office 365. With this post, I would like to dig deeper and explain to you, my loyal blog followers, on how to set a simple retention policy on a SharePoint site.
Real-life Retention Policy Example
Due to industry regulations, we need to retain documents for at least 7 years, after which they can be deleted.
In my example though, I will retain documents for 2 days after they were last modified, then delete them as I do not want to wait for 7 years to finish this article for you 🙂.
Access Security & Compliance Admin Center
- Navigate to the Office 365 Admin Centers
- From the list of available Admin Centers, click on Security & Compliance
How to create and publish a Retention Policy on a SharePoint site
Now that we are in the Security & Compliance Admin Center, we are ready to create and publish a Retention Policy on a SharePoint site.
- Under Data Governance, click Retention
- Hit Create button to create new Retention Policy
- Give your policy a name and description. Hit Next
- On the next screen is where you set up the logic. You can configure how many days, months, or years to retain the content for, specify whether you want the math (retention period) to be calculated from the Created Date or Last Modified Date. Lastly, you can also specify whether you want to keep or delete content after the Retention period expires. Hit Next
- On the next screen, you get to choose where to apply the policy. You can apply it to email (Exchange), SharePoint sites, OneDrive accounts as well as Office 365 Groups.
- In my case, I applied a policy to a single Office 365 Group Site
- On a final screen, you need to review and confirm the settings and click Create this policy button. It is imperative to note the message you get to see at the bottom. It warns you that content might be deleted as soon as the policy takes effect according to the logic you set up in previous steps.
- It says it can take up to 24 hours for a policy to take effect, but in my case, it just literally took minutes. If you go back and click on the retention policy you set up – you will see its status and whether or not it has been deployed.
What happens after you publish a Retention Policy on a SharePoint site
- Your site can no longer be deleted as it now has a compliance policy set on it. If you try to delete it – you will receive an error message: A Compliance policy is currently blocking this site deletion
- Your site will now get a Preservation Hold Library (more on it below). It is a special library that retains content during the retention period in case document has been modified or deleted. To be precise, the Preservation Hold Library is not created until any one file is modified or deleted.
- You will not be able to delete a folder on a site anymore without first deleting its contents. You might find it annoying, but that is how it works when a Retention Policy is set on a SharePoint site. You will now get the following message when you try to delete a folder (that is not empty): You have to delete all the items in this folder before you can delete the folder.
How does Retention Policy on a SharePoint site work?
Every day a timer job scans content on a site and determines its outcome based on a retention policy being set. There are several possible scenarios:
If the user has not deleted the document
If the document in the library has not been modified or deleted by the user, it will be moved to the recycle bin automatically upon the end of the retention period. In such cases, it will state that the files were deleted by System Account and not the human being (screenshot taken from the site Recycle Bin).
If the user has deleted the document
If the users have deleted the document, the file will end up in the Recycle Bin. However, it will also be copied to the Preservation Hold Library I mentioned earlier. This Preservation Hold Library assures that the documents are retained for the duration of the retention period and cannot be deleted. You will notice automatic suffixes added to the deleted documents. The latter part of the suffix contains the date and time stamp designating when the document was moved to the Preservation Hold Library.
Note that if you try to delete a document from the Preservation Hold Library, you will get the error message.
Microsoft had published an excellent post explaining the logic of Preservation Hold Library – they also have a helpful diagram illustrating the workflow. You can access it here.