Backup & Restore
import { Aside } from ‘@astrojs/starlight/components’;
Kotauth can export entire workspaces as encrypted, portable archive files. These snapshots contain all tenant data — users, roles, groups, applications, sessions, audit logs, attributes, claim mappers, and settings — in a single file that can be imported into another Kotauth instance.
Use cases
Section titled “Use cases”- Disaster recovery — maintain encrypted backups of production workspaces
- Environment promotion — export from staging, import to production
- Migration — move a workspace between Kotauth instances
- Testing — snapshot a workspace before running destructive tests, restore afterward
Archive format
Section titled “Archive format”Exports use the bkp1 envelope format — a self-contained binary file containing:
| Section | Content |
|---|---|
| Magic bytes | Format identifier (bkp1) |
| Metadata | Schema version, tenant slug, export timestamp |
| Salt | 32-byte random salt for key derivation |
| IV | 12-byte initialization vector for AES-GCM |
| Ciphertext | AES-256-GCM encrypted tenant data |
Key derivation uses PBKDF2 with 600,000 iterations and the user-provided passphrase. The high iteration count ensures brute-force resistance even if the archive file is leaked.
CLI commands
Section titled “CLI commands”Export a tenant
Section titled “Export a tenant”java -jar kauth.jar cli export-tenant \ --slug=my-workspace \ --output=/backups/my-workspace-2026-05-01.bkp1 \ --passphrase="your-strong-passphrase"| Option | Required | Description |
|---|---|---|
--slug | Yes | Workspace slug to export |
--output | Yes | Output file path |
--passphrase | Yes | Encryption passphrase |
With Docker Compose:
docker compose exec kauth java -jar kauth.jar cli export-tenant \ --slug=my-workspace \ --output=/data/backups/my-workspace.bkp1 \ --passphrase="your-strong-passphrase"Import a tenant
Section titled “Import a tenant”java -jar kauth.jar cli import-tenant \ --input=/backups/my-workspace-2026-05-01.bkp1 \ --passphrase="your-strong-passphrase"| Option | Required | Description |
|---|---|---|
--input | Yes | Archive file path |
--passphrase | Yes | Decryption passphrase |
Admin API
Section titled “Admin API”The same operations are available via the REST API for programmatic backup workflows.
Export
Section titled “Export”POST /admin/api/v1/tenants/{slug}/exportContent-Type: application/jsonAuthorization: Bearer {admin-api-key}
{ "passphrase": "your-strong-passphrase"}Returns the encrypted .bkp1 archive as a binary download (application/octet-stream).
Import
Section titled “Import”POST /admin/api/v1/tenants/importContent-Type: multipart/form-dataAuthorization: Bearer {admin-api-key}
file: <archive.bkp1>passphrase: your-strong-passphraseReturns the imported tenant metadata on success.
Schema compatibility
Section titled “Schema compatibility”Each archive records the database schema version at the time of export. On import, Kotauth checks that the target instance has run at least that migration version. This prevents data corruption from missing columns or tables.
| Scenario | Result |
|---|---|
| Same schema version | Import succeeds |
| Target is newer (has more migrations) | Import succeeds — additional columns use defaults |
| Target is older (missing migrations) | Import fails with schema mismatch error |
Next steps
Section titled “Next steps”- CLI Commands — all available CLI subcommands
- Production Checklist — deployment hardening
- Environment Variables — full configuration reference