Skip to content

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.

  • 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

Exports use the bkp1 envelope format — a self-contained binary file containing:

SectionContent
Magic bytesFormat identifier (bkp1)
MetadataSchema version, tenant slug, export timestamp
Salt32-byte random salt for key derivation
IV12-byte initialization vector for AES-GCM
CiphertextAES-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.

Terminal window
java -jar kauth.jar cli export-tenant \
--slug=my-workspace \
--output=/backups/my-workspace-2026-05-01.bkp1 \
--passphrase="your-strong-passphrase"
OptionRequiredDescription
--slugYesWorkspace slug to export
--outputYesOutput file path
--passphraseYesEncryption passphrase

With Docker Compose:

Terminal window
docker compose exec kauth java -jar kauth.jar cli export-tenant \
--slug=my-workspace \
--output=/data/backups/my-workspace.bkp1 \
--passphrase="your-strong-passphrase"
Terminal window
java -jar kauth.jar cli import-tenant \
--input=/backups/my-workspace-2026-05-01.bkp1 \
--passphrase="your-strong-passphrase"
OptionRequiredDescription
--inputYesArchive file path
--passphraseYesDecryption passphrase

The same operations are available via the REST API for programmatic backup workflows.

POST /admin/api/v1/tenants/{slug}/export
Content-Type: application/json
Authorization: Bearer {admin-api-key}
{
"passphrase": "your-strong-passphrase"
}

Returns the encrypted .bkp1 archive as a binary download (application/octet-stream).

POST /admin/api/v1/tenants/import
Content-Type: multipart/form-data
Authorization: Bearer {admin-api-key}
file: <archive.bkp1>
passphrase: your-strong-passphrase

Returns the imported tenant metadata on success.

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.

ScenarioResult
Same schema versionImport succeeds
Target is newer (has more migrations)Import succeeds — additional columns use defaults
Target is older (missing migrations)Import fails with schema mismatch error