JoaoJandre opened a new pull request, #13939:
URL: https://github.com/apache/cloudstack/pull/13939

   ### Description
   
   This PR adds a feature for periodically sending basic backup reports to 
operators. To enable backup reports, the environment's alert email settings 
must be configured beforehand. To configure the report task, the following 
settings have been added:
   
   | Configuration                | Description                                 
                                                                                
                                                                                
                                     | Default Value |
   | ---------------------------- | 
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 | ------------- |
   | `backup.report.task.enabled` | Enables the periodic backup report task.    
                                                                                
                                                                                
                            | `false`       |
   | `backup.report.period`       | Period, in minutes, between task 
executions. The generated report will contain backups from the last 
`backup.report.period` minutes, as well as a forecast of the next execution of 
backup schedules that may potentially run during the next 
`backup.report.period` minutes. | `1440`        |
   | `backup.report.timeout`      | Timeout in minutes for the report 
generation process. If a Management Server finds a task that has been running 
longer than the configured value, the task will be considered canceled.         
                                                            | `10`          |
   
   Additionally, the `getBackupReport` API has been added to generate reports 
through the API. This API returns the report in the API response and does not 
send emails to operators. The API supports the following parameters:
   
   | Parameter   | Description                                                  
                                                                          | 
Required? |
   | ----------- | 
--------------------------------------------------------------------------------------------------------------------------------------
 | --------- |
   | `zoneid`    | ID of the zone for which the report should be generated.     
                                                                          | No  
      |
   | `domainid`  | ID of the domain for which the report should be generated.   
                                                                          | No  
      |
   | `accountid` | ID of the account for which the report should be generated. 
Mutually exclusive with `projectid`.                                       | No 
       |
   | `projectid` | ID of the project for which the report should be generated. 
Mutually exclusive with `accountid`.                                       | No 
       |
   | `startdate` | Report start date.                                           
                                                                          | Yes 
      |
   | `enddate`   | Report end date. If it is in the future, a forecast of the 
next execution of backup schedules within the period will also be returned. | 
Yes       |
   
   This API is only available to `Admin` accounts.
   
   <details>
   <summary>API Usage Example</summary>
   
   ```json
   (labinterno) 🐱 > get backupreport startdate='2026-06-23' enddate='2026-06-24'
   {
     "backupreport": {
       "backupstoragetotal": 6.224914558231831,
       "domainreport": [
         {
           "accountreport": [
             {
               "account": "admin",
               "accountid": "e3c10cf4-b564-11ee-afc2-5254000a59f7",
               "backupstoragetotal": 3.1328735426068306,
               "deletedbackup": [
                 {
                   "backupofferingname": "standard",
                   "created": "2026-06-23T19:01:24+0000",
                   "id": "b980ef1e-6a95-4aa5-803e-328029020d4e",
                   "name": "da-2026-06-23T19:01:22.803027606Z",
                   "removed": "2026-06-24T19:01:09+0000",
                   "virtualmachineid": "dd3e719e-9063-46a2-8596-85d4f1319199",
                   "virtualmachinename": "vm1",
                   "zone": "zona",
                   "zoneid": "eff81807-ee5f-4397-98ea-855a4b8b541b"
                 },
                 {
                   "backupofferingname": "standard",
                   "id": "8bda5fa7-ff71-4216-b251-c653d5441295",
                   "name": 
"VM-ff96a116-d856-4899-87d2-3ec3cab8a486-2026-06-24T18:08:46.052496381Z",
                   "removed": "2026-06-24T18:11:08+0000",
                   "virtualmachineid": "ff96a116-d856-4899-87d2-3ec3cab8a486",
                   "virtualmachinename": 
"VM-ff96a116-d856-4899-87d2-3ec3cab8a486",
                   "zone": "zona",
                   "zoneid": "eff81807-ee5f-4397-98ea-855a4b8b541b"
                 },
                 {
                   "backupofferingname": "standard",
                   "id": "a5a44ec9-7532-482b-93bf-4cd6b64fcab5",
                   "name": 
"VM-ff96a116-d856-4899-87d2-3ec3cab8a486-2026-06-24T18:14:24.053079158Z",
                   "removed": "2026-06-24T18:15:38+0000",
                   "virtualmachineid": "ff96a116-d856-4899-87d2-3ec3cab8a486",
                   "virtualmachinename": 
"VM-ff96a116-d856-4899-87d2-3ec3cab8a486",
                   "zone": "zona",
                   "zoneid": "eff81807-ee5f-4397-98ea-855a4b8b541b"
                 }
               ],
               "failedbackup": [
                 {
                   "backupofferingname": "standard",
                   "created": "2026-06-24T18:15:22+0000",
                   "failurereason": "No available host found to create backup 
[ae522d32-97af-4069-b311-0e6a25a7f227] of VM 
[dd3e719e-9063-46a2-8596-85d4f1319199]. Setting the backup as Failed.",
                   "id": "ae522d32-97af-4069-b311-0e6a25a7f227",
                   "logid": "f3e8d632",
                   "name": "da-2026-06-24T18:15:22.779064677Z",
                   "virtualmachineid": "dd3e719e-9063-46a2-8596-85d4f1319199",
                   "virtualmachinename": "vm1",
                   "zone": "zona",
                   "zoneid": "eff81807-ee5f-4397-98ea-855a4b8b541b"
                 }
               ],
               "providerinfo": [],
               "sucessfulbackup": [
                 {
                   "backupofferingname": "standard",
                   "created": "2026-06-24T18:15:00+0000",
                   "id": "50d971b4-bdec-4a37-a79b-564058e6f3a8",
                   "name": "da-2026-06-24T18:15:00.489465709Z",
                   "virtualmachineid": "dd3e719e-9063-46a2-8596-85d4f1319199",
                   "virtualmachinename": "vm1",
                   "zone": "zona",
                   "zoneid": "eff81807-ee5f-4397-98ea-855a4b8b541b"
                 },
                 {
                   "backupofferingname": "standard",
                   "created": "2026-06-24T19:01:07+0000",
                   "id": "a9e93b0f-5992-4793-8956-25d7fccdebfe",
                   "name": "da-2026-06-24T19:01:05.567776285Z",
                   "virtualmachineid": "dd3e719e-9063-46a2-8596-85d4f1319199",
                   "virtualmachinename": "vm1",
                   "zone": "zona",
                   "zoneid": "eff81807-ee5f-4397-98ea-855a4b8b541b"
                 },
                 {
                   "backupofferingname": "standard",
                   "created": "2026-06-23T19:02:50+0000",
                   "id": "af163123-12a5-4f76-b683-bc18a67ce141",
                   "name": 
"VM-ff96a116-d856-4899-87d2-3ec3cab8a486-2026-06-23T19:02:48.527866466Z",
                   "virtualmachineid": "ff96a116-d856-4899-87d2-3ec3cab8a486",
                   "virtualmachinename": 
"VM-ff96a116-d856-4899-87d2-3ec3cab8a486",
                   "zone": "zona",
                   "zoneid": "eff81807-ee5f-4397-98ea-855a4b8b541b"
                 }
               ]
             }
           ],
           "backupstoragetotal": 3.1328735426068306,
           "domain": "ROOT",
           "domainid": "8e33df7b-b564-11ee-afc2-5254000a59f7"
         },
         {
           "accountreport": [
             {
               "backupstoragetotal": 3.092041015625,
               "deletedbackup": [],
               "failedbackup": [],
               "project": "project1",
               "projectid": "7ba37e0a-d40e-4812-a030-229ed506c26b",
               "providerinfo": [],
               "sucessfulbackup": [
                 {
                   "backupofferingname": "standard",
                   "created": "2026-06-24T18:18:24+0000",
                   "id": "aaf5f9a1-710c-4755-b973-0e7fec2a3aee",
                   "name": "Test-Project-VM-2026-06-24T18:18:23.624968182Z",
                   "virtualmachineid": "494e2476-ea06-4b88-8af3-3b6c8c533a16",
                   "virtualmachinename": "Test-Project-VM",
                   "zone": "zona",
                   "zoneid": "eff81807-ee5f-4397-98ea-855a4b8b541b"
                 }
               ]
             }
           ],
           "backupstoragetotal": 3.092041015625,
           "domain": "A",
           "domainid": "c5bcdc6a-c138-4483-939e-8b31ccf8b912"
         }
       ],
       "enddate": "2026-06-24T23:59:59+0000",
       "schedulereport": [],
       "startdate": "2026-06-23T00:00:00+0000"
     }
   }
   ```
   
   </details>
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [X] New feature (non-breaking change which adds functionality)
   - [ ] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] Build/CI
   - [ ] Test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [X] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [ ] Minor
   - [ ] Trivial
   
   ### Screenshots (if appropriate):
   
   Example generated email:
   
   <img width="1800" height="1093" alt="image" 
src="https://github.com/user-attachments/assets/176decf0-5cf6-4e32-80d2-01e616473442";
 />
   
   ### How Has This Been Tested?
   
   |Test|Result|
   |---|---|
   |Call the `getBackupReport` API passing only startdate and enddate | All 
backups belonging to the specified period were reported |
   |Call the `getBackupReport` API specifying the domain | Only backups for the 
domain were returned|
   |Call the `getBackupReport` API specifying the account | Only backups for 
the account were returned|
   |Call the `getBackupReport` API specifying the project | Only backups for 
the project were returned|
   |Configure alert email notifications and the backup reporting period to 3 
days| Email received with backups from the last 3 days and the forecast for the 
next 3 days |


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to