Importing volume backups via REST API

Hi everyone,

I’m doing some tests on Incus, more specifically on its storage side, and I have a question about importing backups.

Using the CLI, the process is as simple as running:

ubuntu@lab-incus:~$ incus storage volume import default backup.tar.gz my-volume

On the other hand, I can’t figure out how to do it through the REST API. I’m assuming that, if possible, it involves more steps, just as incus storage volume export seems to translate to three requests:

POST /1.0/storage-pools/{poolName}/volumes/{type}/{volumeName}/backups
GET /1.0/storage-pools/{poolName}/volumes/{type}/{volumeName}/backups/{backupName}/export
DELETE /1.0/storage-pools/{poolName}/volumes/{type}/{volumeName}/backups/{backupName}

Does anyone know how to do this and/or if it is possible to do it via REST API?

Thanks!

Have you tried using --debug flag? It should show you all the API calls of your command:

incus --debug storage volume import default backup.tar.gz my-volume

Yes, I have — in fact, that’s how I figured out how to export the backup via REST API.

In terms of API calls, storage volume import with --debug only returns two which don’t seem to be responsible for the operation itself:

DEBUG  [2025-01-23T12:19:13Z] Connecting to a local Incus over a Unix socket
DEBUG  [2025-01-23T12:19:13Z] Sending request to Incus                      etag= method=GET url="http://unix.socket/1.0"
DEBUG  [2025-01-23T12:19:13Z] Got response struct from Incus
DEBUG  [2025-01-23T12:19:13Z] [truncated]
Importing custom volume: 100% (434.47MB/s)
DEBUG  [2025-01-23T12:19:13Z] Connected to the websocket: ws://unix.socket/1.0/events
DEBUG  [2025-01-23T12:19:13Z] Sending request to Incus                      etag= method=GET url="http://unix.socket/1.0/operations/b4a729bb-a9ab-4046-a8f2-dd1fd7aa4c55"
DEBUG  [2025-01-23T12:19:13Z] Got response struct from Incus
DEBUG  [2025-01-23T12:19:13Z] [truncated]

So, apparently, the heavy lifting is done by the function associated with the storage volume import command itself?