xo-cli examples
-
Hi,
I'm trying to use xo-cli to create jobs and schedules but without succes due to a lack of documentation.
Someone can help me on writing commands for:
- metadataBackup.createJob
- backupNg.createJob
I'll use these commands with a specific remote and a retention to backup metadata, do snapshots and full vm backups.
The job is created with a schedules parameters, do I need to create a schedule before ? What I understood is that the schedule.create method requires a jobId parameter.
Thanks a lot.
-
Pinging @julien-f
-
@olivierlambert merci Olivier
-
@infodavid It's not documented because this API was not intended to be used by the public.
The easiest way to understand how it works is to use the debug mode of xo-web: just append
?debug
to the end of XO URL (but before the#...
part), and then you will be able to see in the browser console all API call made by xo-web and you can figure out exactly what needs to happen to create a backup job. -
@julien-f Thanks Julien, I didn't know that.
0k, if I understand correctly, the debug mode will show the rest methods not the calls ro the xo-cli, is that correct? Maybe the parameters are identical?Best regards,
davide -
@infodavid No, the debug mode will show calls to the JSON-RPC API which is the original XO API used internally,
xo-cli
uses the same API by default, unless using thexo-cli rest
command.The JSON-RPC API and the REST API are completely different, the first one is the oldest and most complete one but was not intended for external use.
-
@julien-f Merci, I'll try and let you know.
-
@julien-f Hi Julien, I've just tested to create a backup job for metadata and got this debugging information.
For schedule and settings, what is the meaning of the key: 'bavyvq5rapl' ?
See the details below.
Thanks for your support.{ "name": "metadata backup", "pools": { "id": "c50afa00-46e5-aa4a-9299-31e3315591b5" }, "remotes": { "id": "40e5ecde-f12f-43c7-befd-c1f0a76e8a25" }, "schedules": { "bavyvq5rapl": { "cron": "0 12 * * *", "name": "daily metadata backup", "timezone": "Europe/Rome" } }, "settings": { "bavyvq5rapl": { "retentionPoolMetadata": 2, "retentionXoMetadata": 2 } }, "xoMetadata": true }
-
@infodavid It's an opaque identifier, it just have to match between
schedules
andsettings
. -
@julien-f 0k, is there a specific rule on the format of this identifier?
When I create a backup, I set an email address for reporting but that address or notification setting) is not present in the JSON, why and how can I set it ?
For rolling snapshots, the content is 0k (same identifier in both settings and schedule):
{ "name": "rolling snapshots", "mode": "full", "schedules": { "gbkk1mbemhg": { "cron": "15 12 * * *", "enabled": true, "name": "daily rolling snapshots", "timezone": "Europe/Rome" } }, "settings": { "": { "concurrency": 2, "nRetriesVmBackupFailures": 3, "timeout": 7200000, "offlineSnapshot": false, "checkpointSnapshot": true }, "gbkk1mbemhg": { "healthCheckSr": "ac595bf5-ca14-586e-6f89-9e4e884043eb", "healthCheckVmsWithTags": [], "snapshotRetention": 2 } }, "vms": { "id": { "__or": [ "64adb2e9-e0f3-9e70-b08f-7c8653415053", "aaf9e807-3ee9-37ff-05ec-cf782ba74d56", "7cd276ae-b7df-06d8-3da8-48262750051d", "9ccfcd0c-a35e-7f45-a0d2-19db678291f1", "42afaaea-ada4-fb7f-dc55-f62a51a6997a", "54b97ba5-9858-a563-e02f-89b0a6c450a1", "9524834a-3577-4445-54c6-1c786775749d" ] } } } Ok for the VM backup using: { "name": "vm backups", "mode": "full", "compression": "zstd", "schedules": { "fdi73l44ewf": { "cron": "40 12 * * 6", "enabled": true, "name": "weekly vm backups", "timezone": "Europe/Rome" } }, "settings": { "": { "concurrency": 2, "nRetriesVmBackupFailures": 3, "timeout": 7200000, "offlineSnapshot": false, "checkpointSnapshot": true }, "fdi73l44ewf": { "exportRetention": 1, "healthCheckSr": "ac595bf5-ca14-586e-6f89-9e4e884043eb", "healthCheckVmsWithTags": [] } }, "remotes": { "id": "40e5ecde-f12f-43c7-befd-c1f0a76e8a25" }, "vms": { "id": { "__or": [ "64adb2e9-e0f3-9e70-b08f-7c8653415053", "aaf9e807-3ee9-37ff-05ec-cf782ba74d56", "7cd276ae-b7df-06d8-3da8-48262750051d", "9ccfcd0c-a35e-7f45-a0d2-19db678291f1", "42afaaea-ada4-fb7f-dc55-f62a51a6997a", "54b97ba5-9858-a563-e02f-89b0a6c450a1", "9524834a-3577-4445-54c6-1c786775749d" ] } } }