Copying OneDrive Folders
You can copy backed-up OneDrive folders to another location in Microsoft OneDrive.
Request
POST https://<hostname>:4443/v6/RestoreSessions/{restoreSessionId}/Organization/OneDrives/{oneDriveId}/Folders/copyTo |
Request Headers
The request header must contain an authorization token of the current session.
Request Parameters
The following parameters must be specified in the URL of the request:
Parameter | Type | Description |
---|---|---|
restoreSessionId | string | Specifies the identification number of the restore session. For more information on how to get this parameter, see Getting Restore Sessions. |
oneDriveId | string | Specifies the identification number of OneDrive. For more information on how to get this parameter, see Getting OneDrives. |
Request Body
To copy backed-up OneDrive folders to another location, the request body must contain the following properties:
Property | Type | Description |
---|---|---|
folders | folder[] | Specifies the IDs of OneDrive folders that you want to copy. For more information on how to get such IDs, see Getting OneDrive Folders. |
userName | string | Specifies the user name that you want to use for authenticating to the organization. Example: "userName": "admin@abcsupport.onmicrosoft.com". |
userPassword | string | Specifies the password of the user account that you want to use for authenticating to the organization. Example: "userPassword": "paSSw0rd". |
oneDrive | oneDrive | Specifies the target destination for the copied OneDrive folders. |
folder | string | Specifies the target folder for the copied OneDrive folders. |
changedItems | boolean | If set to true, indicates that the changed OneDrive items will be copied. |
deletedItems | boolean | If set to true, indicates that deleted OneDrive items will be copied. |
restorePermissions | boolean | If set to true, indicates that the OneDrive items will be copied with all permissions. |
sendSharedLinksNotification | boolean | If set to true, indicates that shared links notifications will be sent. |
documentVersion | string | Specifies what version of the OneDrive documents will be copied. The following values are available:
|
documentLastVersionAction | string | Specifies the action that will be performed with the last version of the copied OneDrive documents on the destination server. The following values are available:
|
userCode | string | Specifies the authentication code. For more information on how to get a device code, see Getting Device Code. This property is required if you want to use a device code for data restore. |
applicationId | string | An identification number of the Azure AD application that you want to use for a restore. |
applicationCertificate | base64 | Specifies the SSL certificate configured for the Azure AD application that you want to use for data restore. You must provide the certificate as a Base64 string. For more information on how to obtain a Base64 string, see Converting Certificate to Base64 String. |
applicationCertificatePassword | string | A password for the SSL certificate being used. |
officeRegion | string | Specifies the region of the target Microsoft 365 organization. The following values are available:
|
organizationName | string | Specifies the name of the target Microsoft 365 organization. |
Converting Certificate to Base64 String
If you want to use a certificate to access an Azure AD application, you must provide the certificate as a Base64 string. To obtain a Base64 string, perform the following steps:
- Get the certificate content from a PFX file.
- Convert the certificate to a Base64 string.
To do this, you can use the following PowerShell cmdlets:
$pfx_cert = get-content '<path_to_cert>' -Encoding Byte [System.Convert]::ToBase64String($pfx_cert) | Out-File '<path_to_file>' |
where:
- <path_to_cert> — path to the PFX file that you want to convert to a Base64 string.
- <path_to_file> — path to a file that that will contain the resulting Base64 string. You will be able to copy the Base64 string from the file and provide the string in the body of a request to Veeam Backup for Microsoft 365 REST API.
For example:
$pfx_cert = get-content 'C:\cert.pfx' -Encoding Byte [System.Convert]::ToBase64String($pfx_cert) | Out-File 'C:\base64.txt' |
For example:
Request Body: { "folders": [ {"id": "bbc9960c-767b-428a-ac6c-c75bb8f7c548"}, {"id": "5e63a8c7-72c8-4070-a7de-6b8e288b0177"} ], "changedItems": true, "deletedItems": true, "restorePermissions": true, "sendSharedLinksNotification": true, "onedrive": { ... }, "folder": "Folder", "documentVersion": "Last", "documentLastVersionAction": "Overwrite", "userName": "administrator", "userPassword": "paSSw0rd", "officeRegion": "Worldwide", "organizationName": "abc.onmicrosoft.com" } |
Response
The server returns the following response to the client.
Response Codes
A successfully completed operation returns a response code 200 OK.
Response Headers
The response to this request contains the following headers. The response may also include additional standard HTTPS headers.
Header | Description |
---|---|
Content-length | The length of the response body. |
Content-type | The media type and syntax of the response body message for the requests with the export and save actions: application/octet-stream. The media type and syntax of the response body message for the requests with the restore and send actions: null. |
Response Body
In the response body, the server returns information about operation results. The response body contains the following properties:
Property | Type | Description |
---|---|---|
totalItemsCount | integer | Specifies the total number of items in the backup. |
restoredItemsCount | integer | Specifies the number of items restored from the backup. |
failedItemsCount | integer | Specifies the number of items for which the restore operation failed. |
skippedItemsByErrorCount | integer | Specifies the number of items that were skipped during the restore operation because of errors. |
skippedItemsByNoChangesCount | integer | Specifies the number of items that were not changed or missing in the original location. Such items are skipped during the restore operation. |
failedRestrictionsCount | integer | Specifies the number of items for which restore of permissions failed during the restore operation. |
restoreIssues | Array of string values | Description of issues that occurred during the restore operation. |
Example
The example shows how to copy folders of the specified OneDrive.
Request: POST https://abc.tech.local:4443/v6/RestoreSessions/445e8385-89fd-4789-a1ca-6f89468a163b/Organization/OneDrives/1d3740ca-bd0e-4656-88ed-2e35ce10e1deef4221af-9351-41ec-9128-534cf34db1a5/Folders/copyTo
Request Header: Authorization: Bearer <Access-Token>
Request Body: { "folders": [ {"id": "bbc9960c-767b-428a-ac6c-c75bb8f7c548"}, {"id": "5e63a8c7-72c8-4070-a7de-6b8e288b0177"} ], "changedItems": true, "deletedItems": true, "restorePermissions": true, "sendSharedLinksNotification": true, "onedrive": { "id": "1d3740ca-bd0e-4656-88ed-2e35ce10e1deef4221af-9351-41ec-9128-534cf34db1a5", "name": "Administrator", "url": "http://server/personal/orgUser" }, "folder": "newFolder", "documentVersion": "Last", "documentLastVersionAction": "Overwrite", "userName": "administrator@abc.onmicrosoft.com", "userPassword": "paSSw0rd", "officeRegion": "Worldwide", "organizationName": "abc.onmicrosoft.com" }
Response: 200 OK
Response Body: { "totalItemsCount": 29, "restoredItemsCount": 0, "failedItemsCount": 0, "skippedItemsByErrorCount": 0, "skippedItemsByNoChangesCount": 19, "failedRestrictionsCount": 0, "restoreIssues": [] } |