RESTful knowledge exchange
Post Reply
mchavigny
Novice
Posts: 5
Liked: 2 times
Joined: Aug 26, 2019 1:16 pm
Contact:

BackupJobSession sortby date

Post by mchavigny »

Hi everybody,

I need to query "BackupJobSession" ordered by date, however, I can't find how.

My current workaround is to sort by name, due to the fact that, date is appended to name.
But, when Job is renamed, this workaround not working.

It's possible to sort "BackupJobSession" by date ?

Current query :

Code: Select all

https://10.10.10.10:9398/api/query?type=BackupJobSession&filter=JobUid==60d09f44-645e-0185-da00-a00b4dcc7b15&pageSize=1&page=1&sortDesc=date
Return :

Code: Select all

{
  "Refs": {
    "Refs": [
      {
        "Links": [
          {
            "Rel": "Up",
            "Href": "https://10.10.10.10:9398/api/backupServers/2a164d6b-1a3f-45b3-89e6-ab12075ab1ff",
            "Name": "veeam-server",
            "Type": "BackupServerReference"
          },
          {
            "Rel": "Up",
            "Href": "https://10.10.10.10:9398/api/jobs/60d09f44-645e-0185-da00-a00b4dcc7b15",
            "Name": "Backup Job Name",
            "Type": "JobReference"
          },
          {
            "Rel": "Alternate",
            "Href": "https://10.10.10.10:9398/api/backupSessions/70b38e55-76aa-4d43-ad50-c6bb2a63e406?format=Entity",
            "Name": "Backup Job Name@2019-05-17 03:15:19",
            "Type": "BackupJobSession"
          },
          {
            "Rel": "Down",
            "Href": "https://10.10.10.10:9398/api/backupSessions/70b38e55-76aa-4d43-ad50-c6bb2a63e406/taskSessions",
            "Type": "BackupTaskSessionReferenceList"
          }
        ],
        "UID": "urn:veeam:BackupJobSession:70b38e55-76aa-4d43-ad50-c6bb2a63e406",
        "Name": "Backup Job Name@2019-05-17 03:15:19",
        "Href": "https://10.10.10.10:9398/api/backupSessions/70b38e55-76aa-4d43-ad50-c6bb2a63e406",
        "Type": "BackupJobSessionReference"
      }
    ]
  },
  "PagingInfo": {
    "Links": [
      {
        "Rel": "First",
        "Href": "https://10.10.10.10:9398/api/query?type=BackupJobSession&filter=JobUid%3d%3d60d09f44-645e-0185-da00-a00b4dcc7b15&pageSize=1&page=1&sortDesc=name"
      },
      {
        "Rel": "Next",
        "Href": "https://10.10.10.10:9398/api/query?type=BackupJobSession&filter=JobUid%3d%3d60d09f44-645e-0185-da00-a00b4dcc7b15&pageSize=1&page=2&sortDesc=name"
      },
      {
        "Rel": "Last",
        "Href": "https://10.10.10.10:9398/api/query?type=BackupJobSession&filter=JobUid%3d%3d60d09f44-645e-0185-da00-a00b4dcc7b15&pageSize=1&page=200&sortDesc=name"
      }
    ],
    "PageNum": 1,
    "PageSize": 1,
    "PagesCount": 200
  }
}
Best regards,

chris.arceneaux
Veeam Software
Posts: 237
Liked: 120 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Kentucky, USA
Contact:

Re: BackupJobSession sortby date

Post by chris.arceneaux » 1 person likes this post

Hi!

It's not possible to sort by date. An alternative would be to include format=Entities as a parameter and sort by CreationTimeUTC on the client side.

GET /api/query?type=BackupJobSession&format=Entities&pageSize=1000&page=1&filter=JobUid==60d09f44-645e-0185-da00-a00b4dcc7b15

Image

mchavigny
Novice
Posts: 5
Liked: 2 times
Joined: Aug 26, 2019 1:16 pm
Contact:

Re: BackupJobSession sortby date

Post by mchavigny » 1 person likes this post

Thank you for your answer,

It's really too bad Veeam Backup API have not this functionality server side, directly in SQL query.
It's work client side but extremely slow compared to API, because, for each Job, you need to get all finished sessions before pass to filter.

Current solution :

Code: Select all

/api/query?type=ReplicaJobSession&filter=JobUid==<uid>&format=Entities&pageSize=265000000' | jq -r '.Entities.ReplicaJobSessions.ReplicaJobSessions | sort_by(.CreationTimeUTC |= fromdate) | .[-1] | .UID'
We have 1 year of history retention session. Not another method exists ?
In future development release, your known if this functionality will be integrated ?

Best regards,

chris.arceneaux
Veeam Software
Posts: 237
Liked: 120 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Kentucky, USA
Contact:

Re: BackupJobSession sortby date

Post by chris.arceneaux »

Comment deleted

ssimakov
Veeam Software
Posts: 357
Liked: 60 times
Joined: Jan 01, 2006 1:01 am
Full Name: Stanislav Simakov
Contact:

Re: BackupJobSession sortby date

Post by ssimakov » 1 person likes this post

It is a bit confusing but sorting by CreationTimeUTC property is possible with sortDesc=CreationTime.

chris.arceneaux
Veeam Software
Posts: 237
Liked: 120 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Kentucky, USA
Contact:

Re: BackupJobSession sortby date

Post by chris.arceneaux »

I can confirm that does work. :) I just tested it.

Kudos @ssimakov!

mchavigny
Novice
Posts: 5
Liked: 2 times
Joined: Aug 26, 2019 1:16 pm
Contact:

Re: BackupJobSession sortby date

Post by mchavigny » 1 person likes this post

It's work, thank you for your reply, :D

In fact, the mistake come to understand relation between query and api url :

https://helpcenter.veeam.com/docs/backu ... l?ver=95u4
>> BackupJobSession have possibility filters to theses value : https://helpcenter.veeam.com/docs/backu ... l?ver=95u4

It's a good idea to update documentation to clarify relation between query and api url :)

Best regards,

veremin
Product Manager
Posts: 17745
Liked: 1615 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: BackupJobSession sortby date

Post by veremin »

May I ask you how the documentation can be improved in your opinion? Thanks!

mchavigny
Novice
Posts: 5
Liked: 2 times
Joined: Aug 26, 2019 1:16 pm
Contact:

Re: BackupJobSession sortby date

Post by mchavigny »

When you read the documentation for the first time, you don't understand immediately the correlation between the "queryType" and API url reference.
In this case, I have not understand the "query=BackupJobSession" corresponding (and have the same filter) that "(GET) /backupSessions/{ID}" detaill here : https://helpcenter.veeam.com/docs/backu ... l?ver=95u4

Now, I understand.
In my company, I have in charge to monitor Backup from monitoring tool. I can use powershell, but I prefer get all result though Enterprise Manager for all Veeam Backup Server and query an unique entry point by Rest API.
But, when you are new user in Veeam Backup Enterprise Manager, that not an evidence the different way to query Rest API.

Best regards,

veremin
Product Manager
Posts: 17745
Liked: 1615 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: BackupJobSession sortby date

Post by veremin »

Got it, I've passed the feedback to technical writers.

Just so you know - you can submit feedback directly to the TW team. To do so click "send feedback" button (any page on the help center, bottom right). Usually, they correct articles quite fast.

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest