Veeam Backup for Microsoft Office 365 RESTful API: Job management
Now that we have our organization added and created our first jobs, we will explore more details on job management such as:
- starting and stopping jobs
- enable or disable jobs
- renaming jobs
- modifying a job schedule
- adding or removing objects from the backup job
- deleting jobs
Starting and stopping a job
There will be moments where you manually want to start or stop a backup job. For both these actions, a JSON is required and we will POST this request against “/v2/Jobs/{jobID}/action” in which we will replace the ID with the job ID related to the job which we either want to start or stop.
If you don’t know the job ID, you can get it via a GET request against “/v2/Jobs“.
To start a backup job we use the following JSON:
{ "start": null }
To start a backup job we use the following JSON:
{ "stop": null }
Enabling and disabling a job
To enable a backup job we use the following JSON:
{ "enable": null }
To disable a backup job we use the following JSON:
{ "disable": null }
All of the above requests can be tested by clicking “Try it out!“. If successful, the job will be modified and it will result in a 200 response code stating the job status change was applied successfully.
Renaming a job
Renaming a backup job is performed via a PUT request against “/v2/Jobs/{jobID}“, this request is always used for modifying job settings. In this example, we will rename the previously created job named “RESTful API demo“.
{ "name": "Renaming via RESTful API" }
After clicking “Try it out!“, the job will be renamed and it will result in a 200 response stating the change was applied successfully.
Modifying the schedule of a job
If you used the same code to create your backup jobs as in part 2, you’ll notice the backup jobs have the same schedule. To modify the schedule of a backup job, we will perform a PUT request against “/v2/Jobs/{jobID}“. The request requires a JSON with the new backup window. In this example, we will change the backup job to only run on weekdays at 22:00. You will notice, we only need to apply the schedule policy.
{
"schedulePolicy": {
"backupWindowEnabled": false,
"type": "Daily",
"dailyType": "Workdays",
"dailyTime": "22:00:00",
"retryEnabled": true,
"retryNumber": 3,
"retryWaitInterval": 10
}
}
After clicking “Try it out!“, the job schedule will be modified and it will result in a 200 response code stating the change was applied successfully.
Adding or removing objects to a job
Just like renaming or modifying the schedule, objects can be added or removed from a job by performing a PUT request against “/v2/Jobs/{jobID}“. In this example, we will modify the previously created job named “Selected items RESTful API demo” and change it from only backing up OneDrive for Business items to also include SharePoint sites.
We can leverage the following JSON to perform this. It is important to explicit define the settings for Exchange (Mailbox and ArchiveMailbox) as well as SharePoint and OneDrive for Business.
{
"SelectedItems":
[
{
"Type": "PartialOrganization",
"Mailbox": false,
"ArchiveMailbox": false,
"OneDrive": true,
"Site": true
}
]
}
After clicking “Try it out!“, the job will be modified and it will result in a 200 response code stating the change was applied successfully.
Deleting a job
A final request which can be performed is deleting a backup job. To remove a backup job, we will send the “DELETE” request to “/v2/Jobs/{jobID}“.
After clicking “Try it out!“, the job will be deleted and it will result in a 200 response code stating the job was deleted successfully.
What’s next?
In the next part, we will take a look at restoring items via several methods. You will learn how to find and restore an e-mail. We will perform a restore to the original location and export to the item as