Veeam Backup for Microsoft Office 365 RESTful API: SharePoint restores

Veeam Backup for Microsoft Office 365 RESTful API: SharePoint restores

This post is based upon the entire organization backup job which we made in part 1, we will dig deeper on how to perform restores for SharePoint.

Starting a restore session

Before we can actually restore a file or folder, we need to start a restore session. We will leverage the organization ID and perform a POST request against “/v2/Organizations/{organizationID}/action“. This will start a Veeam Explorer in the background and return a restore session ID. The restore session ID will be used during the restore process.

To start the restore session, we will leverage the following JSON which starts the Veeam Explorer for SharePoint.

{
  "explore": {
   "datetime": "2019.02.26",
   "type": "vesp"
  }
}

As we want to restore specific SharePoint items (either a list, file or folder), we leverage the type VESP which is short for Veeam Explorer for SharePoint.

This will start the restore session in the background and will result in a 201 response code stating the Veeam Explorer has started. The output contains a restore session ID which we will use in the next parts to perform restores.

Restore possibilities

With the restore session ID, we can now perform the restores as needed. We can restore multiple objects:

  • Complete SharePoint
  • Specific lists, files or folders
  • Multiple lists, files or folders at once

In the following examples, we will restore a complete SharePoint site. Before we can restore it, we need to get the site ID. We can get this via “/v2/RestoreSessions/{restoreSessionID}/Organization/Sites” where we replace the restore session ID. This will result in a list of available sites. Select the site you want to restore and copy the ID as it will be used in the following API requests.

SharePoint sites response

Restore to original location

Now that we have the site ID and the restore session ID, we can start the actual restores. A restore is performed by making a POST call against “/v2/RestoreSessions/{restoreSessionID}/organization/Sites/{siteID}/action“. The JSON to restore to the original location is defined below, make sure you replace the values needed for the username and password accordingly.

{
 "restoreTo":  {
    "userName": "niels.engelen@XXXX.onmicrosoft.com",
    "userPassword": "C00lpa$$word",
    "restorePermissions": true,
    "documentVersion": "last",
    "documentLastVersionAction": "Merge",
  }
}

There are 3 additional parameters available. “restorePermissions“, “documentVersion‘ and ‘documentLastVersionAction‘, these can be used to restore item permisiions and specific document versions.

Upon performing this request, you will get a 200 response code once the restore has been performed.

Working with individual files and folders

If you want to restore a specific file or folder, you can perform a request against “/v2/RestoreSessions/{restoreSessionID}/organization/Sites/{siteID}/Documents” or “/v2/RestoreSessions/{restoreSessionID}/organization/Sites/{siteID}/Folders” to get a list of all available files and folders. SharePoint additionally has multiple available such as lists, libraries and attachments.

The example below will export a document to a ZIP file. To restore the file we perform a POST request against “/v2/RestoreSessions/{restoreSessionID}/Organization/Sites/{siteID}/Documents/{fileID}/Action” containing the following JSON.

{
  "save" : {
    "asZip" : "true"
  }
}

This will result in a ZIP file available for download containing the specific file.

What’s next?

In the next part, we will list a few workflows based upon the past posts via schemes.

Missed a part?

Niels Engelen on GithubNiels Engelen on Twitter
Niels Engelen
Working as a Principal Analyst in Product Management for Veeam Software with an interest in anything virtual and cloud with a strong focus on AWS, Azure and Microsoft 365. He is also a VMware Certified Professional, a Veeam Certified Architect and gained the VMware vExpert award (2012-2022).
Comments are closed.