How to obtain the total amount of Backup storage in GB or TB with a script

Edgar Briseno Admin 0 Reputation points
2025-03-04T19:50:39.7933333+00:00

Hello everyone.

I am working on obtaining the total amount of backup storage space as you can see below, I can get that inside the recovery services vaults pane, but I want to find a way to obtain that same value using a script either PowerShell or Bash, been working on some CLI commands but none of them are working, has somebody done this or can you point me in the right direction please.

User's image

Thank You for your time

Best Regards.

Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,496 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. TP 125.7K Reputation points Volunteer Moderator
    2025-03-04T20:32:09.0666667+00:00

    Hi Edgar,

    You may retrieve usage information (same data you see in portal) via REST API :

    Usages - List By Vault

    https://learn.microsoft.com/en-us/rest/api/recoveryservices/usages/list-by-vaults?view=rest-recoveryservices-2024-10-01&tabs=HTTP

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.
    0 comments No comments

  2. Manu Philip 20,206 Reputation points MVP Volunteer Moderator
    2025-03-04T20:50:39.3166667+00:00

    Hi Edgar Briseno Admin

    Following az cli command can help you out. Please use it by substituting your own variables

    az rest --method GET --url "https://management.azure.com/Subscriptions/yoursubname/resourceGroups/yourgsname/providers/Microsoft.RecoveryServices/vaults/yourvaultname/usages?api-version=2024-10-01"

    Here is the value from portal

    User's image

    az cli shows the corresponding value as follows

    User's image

    Hope this helps.


    --please don't forget to upvote and Accept as answer if the reply is helpful--

    1 person found this answer helpful.

  3. Manu Philip 20,206 Reputation points MVP Volunteer Moderator
    2025-03-05T03:32:28.17+00:00

    Hi Edgar Briseno Admin

    Note the units field in the cli output says the values are in bytes

    However, the azure portal reports the size in GB

    Here is an online converter result and it matches:

    User's image

    1 person found this answer helpful.

  4. Edgar Briseno Admin 0 Reputation points
    2025-03-04T22:59:41.8566667+00:00

    Hello @Manu Philip

    Your command worked but I noticed a discrepancy in the output for the size in the console and from the command you provide, in the console I am getting 84.82 GBs and from the command I am getting 91075183616 bytes which that gives us 91.07 GBs, do you know why is there a difference?

    Web Console

    User's image

    CLI Command

    User's image

    Best Regards.

    0 comments No comments

  5. Edgar Briseno (EXT) 0 Reputation points
    2025-03-12T20:34:28.5433333+00:00

    Thank you .

    Your answers helped me solve this.

    Best Regards.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.