Backups and restore of a service volume
A service that stores data has a volume. A backup is a snapshot of that volume that you take on demand, keep, and can roll the volume back to. These are your snapshots. Separately, Zaroz keeps its own disaster-recovery backups of the platform; they are not listed here and are not something you restore from.
The samples use the helper from Using the Zaroz API. {resource_id} is the id of the service's volume resource: list the service's resources with GET /service-instances/{id}/resources and pick the one of kind volume. Only services whose product has storage and whose cluster supports snapshots can take backups; check the backups entry in the service's capabilities. A service without storage answers 404, the same as one that is not yours.
Take a backup
curl
Code
Code
TypeScript
Code
Python
Code
- A backup starts as
creatingand becomes restorable atready.failedstays in the list until you delete it. max_backupsis the ceiling per volume, published in the listing so you never hard-code it. Past it, creating answers a quota error: delete an old one first.- You cannot start a backup while another backup or a restore is running on the same volume (
409). - A backup is a snapshot of the volume as it is at that moment. When you need a copy that is consistent at the application level (a database mid-transaction), stop writing first or take the database's own dump as well.
Restore
Restoring is irreversible. The workloads that use the volume are stopped, the volume's data is reverted to the snapshot, and then they start again: every change made since the backup was taken is lost. If you might want the current state back, take a backup of it first. The backup must be ready.
curl
Code
TypeScript
Code
Python
Code
While it restores the backup shows status: "restoring" and a restore_phase that moves through stopping_workloads, detaching_pre, maint_attaching, reverting, detaching_post, csi_retaining_pv, csi_recreating_pvc and restarting_workloads. It runs over several minutes; large volumes take longer. Do not start another backup or restore meanwhile (409). Use restore_started_at to show "restoring for N minutes".
Delete a backup
Code
Code
Code
A backup that is creating or restoring cannot be deleted; wait until it is ready or failed. Deleting removes the underlying snapshot.
How full is the volume
curl
Code
Code
Code
capacity_bytes is the configured size (a quota, always present). used_bytes is measured inside the cluster and is null whenever it cannot be measured, so show "unknown" rather than zero. last_backup_at tells you whether your routine is working.
Before you rely on it
- Backups belong to the volume and its subscription. Do not treat them as the only copy of anything you cannot lose if you might delete or cancel the service.
- To keep a copy outside Zaroz, copy the files (see the file routes, or SFTP) or dump the database to object storage.
- Automate it: a nightly job that creates a backup, waits for
readyand deletes the oldest when you reachmax_backupsis a few lines of the code above. Use a token withservices.managescoped to that one service.
