LioranDB TypeScript Series #9: Backups, Cluster Health and Operational APIs
LioranDB TypeScript Series: Build with a developer-first document database powered by Rust and designed for TypeScript.
So far we've mostly treated LioranDB as an application database.
But the driver also exposes the operational side of the server.
Cluster state
const summary =
await client.cluster.summary();
const nodes =
await client.cluster.nodes();
const partitions =
await client.cluster.partitions();
const health =
await client.cluster.health();
const readiness =
await client.cluster.readiness();
This makes operational tooling possible without maintaining a completely separate client stack.
Administrative operations
await client.cluster.checkpoint();
await client.cluster.compact();
These are administrative operations, so treat them accordingly.
Don't put compact() inside the request handler for /api/users.
I shouldn't need to say that, but somewhere a server just became nervous. 🤕
Creating a backup
const backup = await client.backups.create({
label: "production-before-migration",
scope: "local_node",
});
Cluster-scoped backups can also be requested where supported.
Backup jobs are asynchronous
Creating a backup doesn't mean the backup has already completed.
Retrieve its state:
const job = await client.backups.get(
backup.backup_id
);
Production code should poll the job until it reaches its terminal state.
Verify backups
A backup you have never verified is a very optimistic file.
await client.backups.verify(
backup.backup_id
);
Restore
Restores intentionally require explicit confirmation.
const restore = await client.backups.restore(
backup.backup_id,
{
confirmation:
`RESTORE ${backup.backup_id}`,
disable_safety_backup: true,
}
);
Then monitor the restore job:
const restoreJob =
await client.backups.getRestoreJob(
restore.job.job_id
);
Runtime settings
The driver also exposes server settings:
await client.settings.get();
await client.settings.getCors();
await client.settings.getPerformance();
await client.settings.getLimits();
await client.settings.getBackups();
Administrative applications can update the corresponding configuration through the settings service.
That includes areas such as:
- CORS
- performance controls
- server limits
- backup configuration
- backup retention and schedules
Why expose operations through TypeScript?
Because infrastructure increasingly becomes software.
Your internal control plane, managed-database dashboard, backup worker and deployment automation can all talk to the same database through a typed SDK.
That's a much nicer foundation than a folder containing 37 shell scripts named things like:
backup-final-v2-real-final.sh
Resources
Auth & Admin Reference:
https://docs.liorandb.com/docs/driver/auth-and-admin
Documentation: https://docs.liorandb.com
Website: https://liorandb.com
Previous: Part 8 → Auth, Users & Roles
Next: Part 10 → Official LioranDB CLI
Top comments (0)