How to recover SharePoint from ransomware
Stop the spread first: stop OneDrive sync and disconnect any mapped drives to SharePoint on the infected computers. Then restore each affected library to a time before the attack with Restore this library, which undoes the last 30 days of changes in one action. Use version history for single files, the recycle bin for deleted ones, and an administrator's request to Microsoft Support within 14 days for anything those cannot bring back.
Ransomware rarely starts in SharePoint. Microsoft explains how it gets there: "After the ransomware is established, the infected files are synchronized to the online environment by the sync client tool or by various WebDAV methods." The encrypted copies arrive as ordinary edits from a real user's account, which is why the recovery tools are the same ones that undo ordinary edits, applied at scale.
| Recovery option | What it brings back | Who uses it | Time limit |
|---|---|---|---|
| Restore this library | A whole document library, to a chosen time | Site admins | The last 30 days |
| Version history | One file, to an earlier version | Users, from the file's menu | As long as the library keeps versions |
| Recycle bin | Deleted files, folders and libraries | Users, and site collection admins for the second stage | 93 days from deletion |
| Restore your OneDrive | A whole OneDrive, to a chosen time | The user, in OneDrive on the web | The last 30 days |
| Microsoft Support | Content that cannot be restored any other way | An administrator, by support request | 14 days beyond deletion |
| Microsoft 365 Backup | Whole sites, to a restore point | The Microsoft 365 admin center, if backup was set up beforehand | The configured recovery window |
Signs a SharePoint library has been hit
Microsoft lists four signs that a library is infected by ransomware:
- "Most library files have the same Modified By timestamp."
- "Files don't open, and they return a message that states that they're possibly corrupted."
- "Each directory within the library contains several files that have such random names as HELP_DECRYPT and HELP_Recover."
- "Files are renamed or have a file name extension appended."
A burst of deletions with none of these signs may be something else, such as a folder moved to another site. SharePoint mass deletion: attack or folder move? covers how to tell the two apart from the audit log.
Step 1: Stop the spread
Microsoft's first instruction: "Immediately stop OneDrive sync or disconnect the mapped drive to a SharePoint library."
Do this on every computer the affected account uses, before you restore anything. A library restored while an infected computer is still syncing can be encrypted again. Then deal with the account itself with your security team: the changes were made with a real user's credentials.
If people still reach libraries through drive letters, SharePoint mapped network drives explains why Microsoft recommends Sync instead; with Sync there is one place to stop on each computer.
Step 2: Restore the library to a time before the attack
Restore this library rolls a whole document library back to a chosen point in the last 30 days. Microsoft: "If lots of your SharePoint or Microsoft Teams files get deleted, overwritten, corrupted, or infected by malware, you can restore an entire shared document library to a previous time."
- Go to the SharePoint document library you want to restore. In Microsoft Teams, from the Files tab of the channel, select More, then Open in SharePoint.
- Select Settings, then Restore this library.
- On the Restore page, select a date from the list, such as Yesterday, or select Custom date and time.
- Use the activity chart and activity feed to review the recent activities you want to undo. The daily activity chart shows the volume of file activity for each day of the last 30 days, which helps identify "when your files were infected by malware."
- For a custom date and time, select the earliest activity you want to undo. Every activity after it is selected automatically.
- Select Restore. The library returns to the state it was in before the first activity you selected.
What to know before you select Restore:
- Only site admins can start a restore. If Restore this library is not under Settings, you either do not have permission or you are looking at a classic library; the feature is available in the modern experience only.
- It undoes everything after the point you choose, on both files and folders, including wanted changes. Pick the earliest malicious activity, not an earlier day out of caution.
- It depends on version history and the recycle bin. Microsoft: "Restoring files uses version history and the recycle bin." With version history turned off, files cannot be restored to a previous version, and files already removed from the site collection recycle bin cannot be restored.
- Re-uploaded files are skipped. If a file or folder was uploaded again after it was deleted, the restore skips it.
- Failures are logged. Files or folders that cannot be restored are listed in a log file whose name begins with RestoreLog, which you can give to Microsoft Support.
- People see a notice on the library while the restore runs.
- It can be undone. Run Restore this library again and select the restore action you just did.
- It cannot bring back a deleted library. Restore the library from the recycle bin first.
Repeat for each affected library. Restore this library works per library, so a site with several damaged libraries needs a restore in each.
Step 3: Restore single files from version history
For a few files, or files the library restore skipped, restore an earlier version:
- Open the library and select ... next to the file.
- Select Version history. If you do not see it, select More, then Version history.
- In the Version history dialog, hover over the date of an earlier version and select the down arrow.
- Select Restore, then OK.
SharePoint keeps the version you restore from: "It creates a copy and makes it the latest version." Version history is on by default in SharePoint, but if the command is missing it may have been turned off for that library.
Step 4: Restore deleted files from the recycle bin
Ransomware that deletes originals and uploads encrypted copies leaves the originals in the recycle bin. Open Recycle bin on the site, select the items, and select Restore. Items return to the location they were deleted from.
- 93 days in total. "For SharePoint, the retention time is 93 days," counted from the moment the item was deleted, across the site recycle bin and the site collection recycle bin.
- Libraries before files. If a whole library was deleted, restore the library first; its files come back with it.
- The second stage. Items deleted from the site recycle bin move to the site collection recycle bin, where a site collection administrator can restore them.
SharePoint recycle bin covers searching, the second stage and PowerShell restores.
Step 5: OneDrive
The OneDrive of the account that synced the infected files is usually affected too. In OneDrive on the web, select Settings, then Restore OneDrive for a work or school account, choose a date, review the activity, and select Restore. It covers the last 30 days and needs an active Microsoft 365 subscription. When files are restored after automatic ransomware detection, OneDrive provides a suggested restore date. OneDrive deleted files covers the other recovery routes.
Step 6: Ask Microsoft Support within 14 days
When the steps above cannot restore the content, Microsoft keeps one more copy: "SharePoint retains backups of all content for 14 additional days beyond actual deletion." An administrator can contact Microsoft Support to request a restoration any time inside the 14-day window.
Microsoft asks for two things in the request:
- Which site collection URLs have been affected by ransomware?
- When was the last known time that the files were not modified by the ransomware?
Record the second answer while you work through Step 2: the activity chart in Restore this library shows when the changes started.
Microsoft 365 Backup
Microsoft's ransomware guidance also points to Microsoft 365 Backup, which "offers a longer protection time and provides uniquely fast recovery" for scenarios "such as ransomware or accidental or malicious employee content overwrite or deletion." It only helps with sites that were included in a backup policy before the attack.
| Microsoft 365 Backup for SharePoint | |
|---|---|
| What is protected | All or selected SharePoint sites |
| Restore points | Every 10 minutes for the two weeks before; weekly beyond that, through the configured recovery window |
| Recovery window | 3 months, 6 months, or 1 to 10 years, set on the backup policy |
| Restore | A full site rollback, in place or to a new URL. Microsoft: it overwrites "all content and metadata since that prior point in time" |
| Cost | Pay-as-you-go: $0.15 per GB per month for the data protected; restores are free |
Microsoft 365 Backup covers coverage and cost in more detail, and backup vs archive vs retention explains which problem each one solves.
After 30 days, and after 93
The native tools are time-boxed. Restore this library reaches back 30 days, the recycle bin 93 days, and Microsoft Support 14 days beyond deletion. An attack noticed late, or files deleted long before anyone looks, can fall outside all three. Squirrel's Recycle Bin Capture archives deleted files into your own Azure Blob Storage before the recycle bin expires them, so a deletion found months later can still be restored.
Frequently asked questions
How do I restore a SharePoint library after ransomware?
Stop OneDrive sync and disconnect mapped drives on the infected computers. Then open the library, select Settings, then Restore this library, choose the time just before the first malicious change, and select Restore. Only site admins can start a restore, and it reaches back 30 days.
How far back can Restore this library go?
The last 30 days. The activity chart shows each of those days, so you can pick the point just before the attack began.
Can I undo a library restore?
Yes. Run Restore this library again and select the restore action you just did.
Why is Restore this library missing?
Either you do not have permission, since only site admins can start a restore, or you are in a classic library. The feature is available for the modern experience only.
What are the signs of ransomware in SharePoint?
Microsoft lists most files sharing the same Modified By timestamp, files that will not open and report corruption, files named HELP_DECRYPT or HELP_Recover in every folder, and files renamed or given an extra extension.
Can Microsoft restore my SharePoint site after a ransomware attack?
SharePoint keeps backups of all content for 14 days beyond deletion. If content cannot be restored with the standard tools, an administrator can contact Microsoft Support to request a restoration within that window, giving the affected site URLs and the last time the files were unaffected.
Does ransomware spread to SharePoint through OneDrive sync?
That is the route Microsoft describes: infected files are synchronized to SharePoint by the sync client or by WebDAV connections such as mapped drives. That is why stopping sync comes first.
Does Restore this library need version history?
Yes. Microsoft states that restoring uses version history and the recycle bin, and that with version history turned off, files cannot be restored to a previous version.
Related reading
- SharePoint mass deletion: attack or folder move? - reading the audit log after a burst of deletions.
- SharePoint recycle bin - the two stages, the 93 days and PowerShell restores.
- OneDrive deleted files - restoring a OneDrive and its files.
- Microsoft 365 Backup - what Microsoft's backup covers and costs.
- Backup vs archive vs retention in Microsoft 365 - which one solves which problem.
- SharePoint mapped network drive - the WebDAV route ransomware can use, and the alternative.
- SharePoint document library security - protecting the files in a library.
Mark Smith co-founded SmiKar Software in 2015 and has spent the past decade helping organisations solve Microsoft 365 data management challenges. He works with the SmiKar team to build solutions for SharePoint archiving, storage optimisation, governance and compliance, supporting customers from growing businesses through to Fortune 500 enterprises.
More about SmiKar


