Skip to main content

Repository Backup & Restore

OctoMesh provides comprehensive backup and restore capabilities for repositories through the octo-cli tool. These operations are executed by the bot service and ensure data integrity and availability for disaster recovery scenarios.

Repository Backup​

By default a backup contains the tenant's MongoDB repository data (entities, associations, and metadata) as a compressed *.tar.gz. With the --include-archive-data option the backup additionally captures the tenant's CrateDB stream-data archives, producing a larger *.octobak.zip container. Backups are performed using the dump command.

Backup Command Syntax​

octo-cli -c dump -tid <tenant-id> -f <output-file> [--include-archive-data]

Parameters​

ParameterDescriptionExample
-c dumpCommand to create backupRequired
-tid <id>Tenant ID to backupsbeg, energy-community
-f <file>Output file path. Use *.tar.gz for a MongoDB-only backup, or *.octobak.zip when including archive data./backup.tar.gz, ./backup.octobak.zip
-iad, --include-archive-dataAlso include the tenant's CrateDB stream-data archives (produces an *.octobak.zip). Requires stream data enabled on the tenantOptional

Backup Example​

# MongoDB-only backup of the 'sbeg' tenant
octo-cli -c dump -tid sbeg -f ./sbeg-backup-2025-08-12.tar.gz

# Backup including CrateDB stream-data archives (produces an .octobak.zip)
octo-cli -c dump -tid sbeg -f ./sbeg-backup-2025-08-12.octobak.zip --include-archive-data

Backup Content​

A plain *.tar.gz backup contains the MongoDB repository data:

  • All runtime entities and their attributes
  • Association data linking entities
  • Construction kit metadata
  • AutoIncrement states (the counters of the number ranges)
  • Tenant configuration and settings
  • Index definitions and constraints
  • Identity data: users (with their encrypted password hashes and two-factor keys), roles, groups, clients and identity providers. A dump and restore is therefore the way to copy a tenant together with its users; a runtime export and ImportRt cannot carry users since System.Identity 2.28.0 (see Moving Users to Another Tenant)

When --include-archive-data is used, the artifact is an *.octobak.zip that wraps the MongoDB dump plus the tenant's CrateDB stream-data archives (one NDJSON file per archive) and a manifest describing each archive's schema and row count.

tip

To export or import the rows of a single archive (rather than a whole tenant), use the dedicated ExportArchiveData and ImportArchiveData commands. See the Stream Data archives guide for the archive concepts.

Data Permissions and Required Role​

A dump is a physical backup of the whole tenant database. It therefore contains all data of the tenant and bypasses data permissions by design: row-level data permissions cannot be applied to a backup, so a dump also contains entities that the requesting user could not read through the API. The protection is the access gate, not a row filter: dump, restore, the archive data export and import, and the download of the resulting file require the tenant role TenantManagement in the caller's token. Without the role the request is refused with 403 and no job is started. Grant this role only to administrators who may see all data of the tenant.

The runtime-data exports (ExportRtByQuery, ExportRtByDeepGraph) are different: they run with the data permissions of the caller. See Data permissions.

Backup as an Asynchronous Method​

A tenant administrator can start the backup through the CK method System.Bot/TenantRepository.Dump-1 (from System.Bot 3.7.0); octo-cli -c dump uses it for the tenant of the context (see Following the backup with octo-cli). It is an asynchronous method: the call returns an operation handle at once, and state, progress and the result are read with runtime.operations.

mutation {
runtime {
systemBotTenantRepositorys {
dump(input: { includeArchiveData: false }) {
invocationId
operation { operationId acceptedAtUtc retryAfterSeconds }
}
}
}
}
query {
runtime {
operations(operationId: "cb869c2aec9046249c0a7e10a8b4af5c") {
items {
state
progress { percent stageCode parameters { name value } }
result
error { code parameters { name value } }
}
}
}
}
StateMeaning
RUNNING with stage QUEUED, DUMPING_DATABASE, EXPORTING_ARCHIVES (parameters archive, archiveCount) or STORING_ARTIFACTThe backup job runs. Every progress report carries the parameter jobId. Progress is reported per stage and per archive.
SUCCEEDED, result = { "jobId": "…", "downloadPath": "<tenant>/v1/jobs/download?id=<jobId>" }Download the file from the bot service with GET <downloadPath> (the same download as for octo-cli -c dump).
FAILED, DUMP_FAILED (jobId)The backup job failed; the job status (system/v1/jobs?id=<jobId>) shows the error.
FAILED, DUMP_FAILED (jobId, reason = another-dump-running)Another backup started by the method ran for more than 10 minutes; this one did not start. Try again later.
FAILED, DUMP_INTERRUPTED (jobId)The job had started and the bot service stopped while it ran. It is not started again.
FAILED, METHOD_OUTCOME_UNKNOWN (reason = handler-lost)The bot service that ran the operation stopped or crashed. Start a new backup.
  • Same job. The method starts the same backup job as the REST call, so the job status and the download work for it as for any other backup. Older octo-cli versions keep using the REST call unchanged.
  • At most once. A backup started by the method is never repeated: neither after a failure nor after a restart of the bot service.
  • Permissions. The method requires the role TenantManagement in the tenant the token was issued for (otherwise METHOD_FORBIDDEN). That is the tenant of the call — or, for a user token, its direct parent tenant (or the system tenant): an administrator of a parent tenant calls the backup, restore and archive data methods on a child tenant and reads their operations there, with the role TenantManagement in the parent tenant and no role in the child tenant (Parent-tenant administration through CK methods). octo-cli -c dump for a child tenant still uses the REST job (next section).
  • Retention. The operation can be read for 7 days after it ended by default (the platform setting allows 1 hour to 30 days); the backup file itself follows the retention of the bot service's artifact store.

Following the Backup with octo-cli​

For the tenant of the context, octo-cli -c dump starts the backup through the method, prints the operation id and the progress (state, stage, percent, job id) and downloads the file when the operation has succeeded. Between two status reads it waits as long as the service suggests (retryAfterSeconds).

octo-cli -c dump -tid sbeg -f ./sbeg-backup.tar.gz
# Dump operation '93c1a391ba834f71815763e7897cc2cf' accepted (System.Bot/TenantRepository.Dump-1)
# Dump operation '93c1a391ba834f71815763e7897cc2cf': RUNNING, stage QUEUED, 0 % (jobId=6af38cb3576adc05c54ede3c)
# Dump operation '93c1a391ba834f71815763e7897cc2cf': SUCCEEDED, stage STORING_ARTIFACT, 80 % (jobId=6af38cb3576adc05c54ede3c)
# Dump operation '93c1a391ba834f71815763e7897cc2cf' succeeded with job id '6af38cb3576adc05c54ede3c'
  • REST fallback. The command uses the REST job (as older versions do) when the asset repository or the bot service does not offer the method yet, and for a tenant other than the tenant of the context (for example a child tenant dumped with the parent's context; the method accepts the parent's user token, but the command does not use it there yet).
  • Failures. DUMP_FAILED, DUMP_INTERRUPTED and METHOD_OUTCOME_UNKNOWN end the command with an error that names the code and its parameters; nothing is downloaded.
  • Reading the operation again. The operation can be read for the retention period (7 days after it ended by default), also after the command was stopped (stopping the command does not stop the backup): GetOperation -id <operationId> shows state, progress and result (-w waits until it has ended), ListOperations lists the caller's operations (-m System.Bot/TenantRepository.Dump-1, -s Failed; -a lists every caller's operations for tenant administrators).

Repository Restore​

Repository restoration recreates tenant data from backup archives. The restore process handles both new tenant creation and existing tenant replacement scenarios.

Restore Command Syntax​

octo-cli -c restore -tid <tenant-id> -db <database-name> -f <backup-file> -w [--restore-archive-data]

Parameters​

ParameterDescriptionExample
-c restoreCommand to restore backupRequired
-tid <id>Target tenant IDsbeg, energy-community
-db <name>Target database namesbeg, production-db
-oldDb <name>When the database had a different name before, you can use this option to be able to restore it to a "new" tenant namesbeg, production-db
-f <file>Backup file path. Accepts a *.tar.gz (MongoDB-only) or an *.octobak.zip (MongoDB + archive data)/path/to/backup.octobak.zip
-rad, --restore-archive-dataAlso restore the CrateDB stream-data archives from an *.octobak.zip. No-op on a plain *.tar.gzOptional
-wWatch mode for progress monitoringOptional but recommended

Restore Example​

# Restore 'sbeg' tenant from backup file
octo-cli -c restore -tid sbeg -db sbeg -f /users/gerald/Downloads/mongodb-backup-sbeg-2025_08_12_03_00.tar.gz -w

Restore Behavior​

The restore operation follows specific rules based on the target tenant's existence:

Existing Tenant​

  • Complete Replacement: If the tenant already exists, it is completely replaced with backup data
  • Data Overwrite: All existing entities, associations, and configurations are removed
  • Downtime: The tenant is temporarily unavailable during the replacement process

New Tenant​

  • Fresh Creation: Creates a new tenant with the specified tenant ID
  • Database Attachment: Attaches the tenant to the specified database
  • Configuration Setup: Establishes all necessary indexes and constraints

Target Database​

The MongoDB part of a restore replaces the target database completely. So before it writes anything, and before it removes an existing tenant, the restore checks who the target database belongs to. It refuses when the target database:

Target databaseWhy it is refused
is the system database of this installationThe restore would overwrite the entire platform.
is admin, local or configThese databases belong to MongoDB itself.
is registered to another tenant of this installationThe restore would overwrite that tenant's data. The message names the tenant.
is the system database of another OctoMesh installation on the same MongoDB serverThe restore would overwrite that entire installation.
belongs to another OctoMesh installation on the same MongoDB serverThe restore would overwrite the other installation's data.
does not start with the installation's tenant-database prefix (System:TenantDatabasePrefix, see Tenant database prefix)Unless it is the current database of the same tenant.

A refusal because of a system database (of this or another installation), a database of another installation or the tenant-database prefix answers with the same conflict as an attach or a delete of an unavailable database: Database name '<name>' is not available. The answer does not say why, so that a caller cannot use the restore to find out which databases other installations on the MongoDB server own. The reason, with the owner's system database and, when the database records it, the tenant, is written to the log of the bot service only, as a warning that starts with Refused the restore of tenant. A refusal because of MongoDB's own databases or a database registered to another tenant of this installation names the reason in the message.

Several OctoMesh installations can share one MongoDB server, each with its own system database. A tenant database records which installation owns it (its system database); an installation owns a database from the moment it creates or attaches it, and gives it up when it detaches it. A database that records no owner, because it was attached before the installations recorded ownership, still belongs to the installation whose system database registers it as a tenant database. That also holds for a registered name whose database does not exist. To restore into a database of another installation, detach the tenant there first, or restore into a new database name.

The restore recognises the system database of another installation by the marker the installation writes into its own system database, so the system database of an installation without any tenant is refused as well. An installation writes this marker when it creates its system tenant and on every start of its identity service; until an installation runs a version that writes it, its system database is recognised by the tenants it registers.

A restore into a new database, into a database of a tenant this installation owns, or into a database no installation owns (for example a detached one) works as before. The ownership that the backup carries from the installation it was taken on is not kept: after the restore the restoring installation owns the database. A backup taken on another installation can therefore be restored and attached.

An administrator can deliberately override the refusal for a tenant database of another installation with --override-foreign-ownership (-ofo) of the octo-cli Restore command (REST: query parameter overrideForeignOwnership=true of restore-from-upload). The restore then overwrites that database, and the bot service writes a warning to its log that starts with OWNERSHIP OVERRIDE and names the previous owner. The override is meant for a database that records another installation as its owner while no installation registers it any more, for example after that installation was removed. A database that another installation still registers is refused with the override too, because the restore attaches the tenant and one database must never be registered in two installations; detach the tenant there first. All other refusals, including the system database of another installation, cannot be overridden.

octo-cli -c Restore `
-tid "mytenant" `
-db "mytenant_db" `
-f "./backup.tar.gz" `
-ofo `
-w

Restore and Archive Data as Asynchronous Methods​

From System.Bot 3.8.0 the restore and the export and import of a single archive's rows are CK methods of System.Bot/TenantRepository as well, with the same operation handle as the backup method: the call returns at once, and state, progress and the result are read with runtime.operations. All three require the role TenantManagement in the tenant the token was issued for, and the token must be issued for the tenant of the call; two exceptions: a user token of the direct parent tenant (or of the system tenant), with the role there (parent-tenant administration), and a client-credentials (service) token whose client is on the allow-list TenantAuthorization:CrossTenantServiceClientIds (see the caller's tenant). The same rule as for the backup method.

Method (GraphQL field below runtime.systemBotTenantRepositorys)ParametersResult when SUCCEEDED
Restore-1 (restore)tusFileId, databaseName, optional oldDatabaseName, restoreArchiveData{ jobId, archiveCount, failedArchiveCount, secretsToReEnterCount }
ExportArchiveData-1 (exportArchiveData)archiveRtId, optional fromUtc, toUtc (half-open window; both omitted = whole archive){ jobId, downloadPath, rowCount }
ImportArchiveData-1 (importArchiveData)tusFileId, archiveRtId, optional mode (INSERT_ONLY default, UPSERT){ jobId, rowCount }
mutation {
runtime {
systemBotTenantRepositorys {
restore(input: { tusFileId: "a1b2c3", databaseName: "sbeg", restoreArchiveData: true }) {
invocationId
operation { operationId acceptedAtUtc retryAfterSeconds }
}
}
}
}

Upload first. Restore-1 and ImportArchiveData-1 read a file uploaded to the bot service's tus endpoint of the tenant (<bot service>/<tenant>/v1/tus-upload, the upload octo-cli does for restore and ImportArchiveData). When the upload with this id does not exist for the tenant, is not complete or is empty, the call is answered at once with UPLOAD_NOT_FOUND (parameter reason = not-found, incomplete or empty) and nothing starts. An upload of another tenant is "not found".

Progress.

MethodStages
Restore-1QUEUED, PREPARING_UPLOAD (5 %), RESTORING_DATABASE (20 %), RESTORING_ARCHIVES (50-85 %, parameters archive, archiveCount), SWEEPING_SECRETS (90 %)
ExportArchiveData-1QUEUED, EXPORTING_ROWS (parameter rows, every 10,000 rows)
ImportArchiveData-1QUEUED, VALIDATING, IMPORTING_ROWS (parameter rows), FREEZING_ROLLUP_WINDOW (rollup archives)

The row stages have no percentage: the number of rows is known only at the end. Every report carries the parameter jobId.

Errors.

ErrorMeaning
RESTORE_FAILED, ARCHIVE_EXPORT_FAILED, ARCHIVE_IMPORT_FAILED (jobId)The job failed. The job status (system/v1/jobs?id=<jobId>) names the reason, for example a schema mismatch, an archive that is not disabled, an unknown archive or a failed database restore.
the same codes with reason = another-job-runningAnother job of the same kind started by a method held the lock for more than 10 minutes; this one did not start. Try again later.
RESTORE_INTERRUPTED, ARCHIVE_EXPORT_INTERRUPTED, ARCHIVE_IMPORT_INTERRUPTED (jobId)The job had started and the bot service stopped while it ran. It is not started again. A restore or import may have written part of its data; run it again.
METHOD_OUTCOME_UNKNOWN (reason = handler-lost)The bot service that ran the operation stopped or crashed.
  • Same jobs, at most once. The methods start the same jobs as the REST calls; a job started by a method is never repeated, neither after a failure nor after a restart of the bot service.
  • The restore keeps its own operation. A restore replaces the tenant's database. The operation is stored outside it (in the system database), so you read its outcome through the handle during and after the restore.
  • Deleted tenants. When a tenant is deleted, its operations are removed as well; a new tenant with the same id never sees them. A restore (including the restore operation itself) and a detach keep the operations.
  • Download an export with GET <downloadPath> from the bot service (<tenant>/v1/jobs/download?id=<jobId>), the same download as for a backup.
  • Retention. An operation can be read for 7 days after it ended by default.

The job API system/v1/jobs is deprecated​

With the methods above, the backup, the restore and the archive data export and import no longer need the job polling API of the bot service. GET system/v1/jobs, GET system/v1/jobs/download and DELETE system/v1/jobs/{id} are therefore deprecated (wave "Bot jobs 1", see Deprecated REST Endpoints): the OpenAPI document marks them deprecated and their calls are counted. They keep working unchanged. The "deprecated since" date is set at rollout, and not before every job type that reports only through this API (RT import and export, CK import, fixup scripts, secret sweep) has an operation handle as well; the sunset date is to be announced.

Large Tenants: Backup Formats and Requirements​

Read this section before you back up or restore a tenant with large stream-data archives (hundreds of millions of rows). The commands are the same as above; what changes is how the archive data travels and what the installation must provide.

Two formats​

A backup with archive data is always one *.octobak.zip with the same name pattern and the same commands (dump --include-archive-data, restore --restore-archive-data). Inside, it comes in one of two formats; the file manifest.json in the container records which one (formatVersion). A restore detects the format by itself.

Format 1Format 2
formatVersion12
Archive dataOne NDJSON file per archive, every row read and written through the serviceThe files CrateDB itself writes with COPY TO (compressed JSON, cut into time slices), copied byte for byte
NeedsNothing beyond the bot serviceAn S3 or Azure Blob artifact store and a CrateDB with the job log filter set (see below)
ContainerWritten to a local file, then storedStreamed straight into the artifact store, no local copy of the container
Rollups after the restoreChecked and repaired (see After a restore)Checked and repaired, the same way

A dump uses format 2 when the requirements below are met and falls back to format 1 otherwise; the job log names the reason. A restore of a format 2 backup never falls back: it refuses, before it touches the tenant, when a requirement is missing (see Readiness check). A restore into another tenant id works, the files hold no tenant id.

Requirements for format 2​

RequirementSettingNotes
Artifact store of kind S3 or AzureBlobArtifactStorage:ProviderThe staging area for the COPY files is the category copy-staging of this store. Give it a lifecycle rule that expires objects after one day; a run deletes its own files at the end, the hourly cleanup removes the files of a crashed run after Bot:ArtifactRetentionHours (24 h).
Job log filter on the CrateDB clusterstats.jobs_log_filterCrateDB records every finished statement with its full text in sys.jobs_log; for a COPY to S3 that text contains the secret key. The filter keeps COPY statements out. Set it once per cluster as a superuser (see below).
S3 endpoint as CrateDB reaches itArtifactStorage:S3:CrateDbServiceUrl, environment OCTO_ARTIFACTSTORAGE__S3__CRATEDBSERVICEURLOnly needed when CrateDB reaches the store under a different address than the bot (for example a cluster-internal service name). Scheme, host and port only, http or https; no path, query or user info. Empty means CrateDB uses S3:ServiceUrl.
S3 key and secret without a colonS3:AccessKeyId, S3:SecretAccessKeyCrateDB splits the key from the secret at the first : of the location, even when it is percent-encoded. A key or secret that contains a colon is refused.
Azure account keyAzureBlob:AccountKey or a connection string with an AccountKeyThe platform issues a shared access signature (SAS) per run for the COPY statements, which needs the key. A managed identity alone is not enough; without a key the dump falls back to format 1.
Azure SAS lifetimeAzureBlob:StagingSasLifetime, environment OCTO_ARTIFACTSTORAGE__AZUREBLOB__STAGINGSASLIFETIME (for example 04:00:00)Default 2 hours, must be greater than zero. The signature is issued when the run starts and must outlast the whole run; a dump or restore that runs longer fails when the signature expires. Set it to a multiple of the expected duration.
Disk space on the CrateDB nodesThe restore compares the room each node has below the high disk watermark with the expected size, for the whole backup before it changes anything and again for each archive. A table takes up to twelve times its compressed size. See Disk and heap headroom.
Heap of the CrateDB nodesCRATE_HEAP_SIZEGive each node at least 2 GiB of heap for archives of this size (measured, see below). See Disk and heap headroom.

The job log filter is a cluster setting. Run it once per CrateDB cluster, with a superuser:

SET GLOBAL PERSISTENT "stats.jobs_log_filter" = 'stmt NOT ILIKE ''copy %''';

All other statements are still recorded. Keep stats.jobs_log_persistent_filter at its default (false), so no statement text is written to the server log.

MongoDB restore: batch size​

The MongoDB part of every restore (format 1 and 2) runs mongorestore. Its default of 1000 documents per bulk insert can produce a message above the 48,000,000 bytes the MongoDB server accepts once the documents of a collection average more than about 48 KB. The restore then stops with a message such as msgLen 48000084 > 48000000 and drops the connection (seen with mongorestore 100.16.0 on a collection of 864,070 documents of about 73 KB each).

The platform therefore always passes an explicit batch size:

SettingEnvironment variableDefaultValid
System:MongoRestoreBatchSizeOCTO_System__MongoRestoreBatchSize1001 to 1000

With 100 documents per batch a message stays below the limit for collections that average up to about 480 KB per document. Lower the value when a collection averages more; raise it when the tenant holds only small documents and the restore is slow. A value outside 1 to 1000 stops the service at start with a message that names the setting.

Readiness check​

Before a restore of a format 2 backup changes anything, it asks the CrateDB cluster (not the tenant) whether the native copy can run. The check only reads two cluster settings; it changes nothing. The restore stops, names the reason and leaves the tenant exactly as it was when:

  • the backup is format 2 with archive data and the installation has no staging area (no artifact store, a FileSystem store, or Azure without an account key);
  • the stream-data storage does not support the native copy;
  • the job log filter stats.jobs_log_filter is not set (the message contains the statement to run);
  • the storage cannot be asked (for example CrateDB is not reachable);
  • the archive data of the backup does not fit on the nodes below the high disk watermark (see Disk and heap headroom); the message gives needed, available and room per refused node.

The same check runs again before the first archive table is touched. If the filter disappears while the archives are loaded, the restore stops after the archive in progress and reports the remaining archives as not attempted.

An unknown formatVersion is refused with the list of supported versions (1 and 2).

Disk and heap headroom​

A restore loads the archive tables slice by slice (about two million rows each) and needs two things from the CrateDB cluster: disk space on every node and memory (heap) for the COPY statements.

Disk. CrateDB stops allocating shards to a node whose disk usage is above the high watermark (cluster.routing.allocation.disk.watermark.high, default 90 %) and makes the tables on a node read-only at the flood stage (...watermark.flood_stage, default 95 %). The restore therefore does not compare the expected size with the free space but with the room below the high watermark: a percentage (90%) or a ratio (0.9) is the share of the disk that may be used, an absolute value (100gb) the free space that must remain.

The expected size per node is

staged size of the archive files x 12 x copies of every shard / nodes
  • Staged size is the sum of the compressed *.json.gz files of the backup (the size of the *.octobak.zip minus the MongoDB part).
  • 12 is a measured safety factor for the size right after the load (before the segments are merged); a table takes less after the merge. It may be refined.
  • Copies is min(1 + replicas, nodes): the tables are loaded without replicas and get their replica setting back (default 0-1) before the merge, so on a cluster of two or more nodes every node holds one copy of the data (two copies over two nodes), on one node there is one copy.

Example, the sbeg tenant (119.5 million raw rows and five rollups, 3.3 GB of compressed archive files): 3.3 GB x 12 = about 39 GB on one node, or on each of two nodes with one replica. A node with a 31 GiB volume that is already 38 % full has about 16 GiB of room below the 90 % watermark, so the restore is refused; the archive tables of this tenant need about 28 GiB per node even after the merge.

The restore checks the whole backup before the MongoDB phase, so a refusal leaves the tenant as it was. The job result names the node and the three figures, for example: Loading the archive data of the backup needs about 36.7 GiB per node (12 times the 3.1 GiB of staged files, 2 copies of every shard over 2 node(s)), but node 'data-hot-1' has 19.1 GiB available and room for 16.2 GiB below the high disk watermark (90%). Nothing was restored. The check is repeated for each archive right before its table is touched, with the disk as it is then (earlier archives count as used). Space that the restore frees by replacing the tables of the target tenant is not subtracted; delete the old archive tables first when that is what makes the difference.

Remedies, in this order: free disk space or add a node; restore a smaller tenant first; as a last resort raise the watermarks (SET GLOBAL PERSISTENT "cluster.routing.allocation.disk.watermark.high" = '95%' with the flood stage above it) - this only moves the limit, the table is still read-only at the flood stage.

Heap. Each COPY FROM of a slice and the segment merge after the load run inside the CrateDB JVM and are charged to its circuit breakers (indices.breaker.total.limit, default 95 % of the heap, 972.7 MB for a 1 GiB heap; indices.breaker.query.limit, default 60 %). Measured with the 150 million row sbeg tenant on one node: with a 2 GiB heap the restore completed; with a 1 GiB heap the load of the raw archive (119 million rows) completed, but one slice needed three attempts (attempt 1: the breaker refused the statement with Allocating 2mb for 'parent: copyFrom: 0' failed; attempt 2: the load reported 1,962,139 of 2,002,104 rows with error_count = 0), and the merge of the loaded table to one segment per shard (about 40 million rows each) ran the node out of memory (OutOfMemoryError in the terms writer of the merge; the node exits and restarts). The restore therefore merges a table into segments of at most 10 million rows per shard, not into a single one; the merged table is not any bigger. A merge that fails or takes the node down does not fail an archive whose rows are loaded: the restore logs it and waits for the node to answer again (up to two more tries after 30 and 60 seconds). Do not raise the heap by hand to make a restore pass without looking at the log: the retries and the heap readings before each repeat are in it.

Failed slices are repeated. A slice that CrateDB refuses for a temporary reason (memory circuit breaker, rejected execution, a node or shard that is not available, a statement timeout, or a load that returns fewer rows than the manifest without reporting an error) is loaded again, at most three attempts in total, after 30 and 60 seconds, with the batch size halved each time (bulk_size 5000, then 2500) and rows that the failed attempt already wrote overwritten by identical ones. Every failed attempt is in the bot log with the archive, slice, attempt and reason; the heap of the nodes is logged before a repeat. Only if the third attempt fails too, the archive fails (... (after 3 attempts)); any other error (a missing column, an unreadable file, a credential error) fails at once as before. A two-node cluster can lose rows without CrateDB reporting an error when the circuit breaker refuses a batch on the second node; the restore counts the rows of every slice and repeats a short one.

Sweep grace period and disk space​

A recompute of a rollup keeps the superseded rows until the sweep, so that a dump that copied the generation map before the recompute still finds the rows its copy names. The delay is StreamData:Recompute:SweepGracePeriod (environment variable OCTO_STREAMDATA__RECOMPUTE__SWEEPGRACEPERIOD, default two hours, 00:00:00 sweeps at once). Choose it above the longest dump of a rollup.

Plan disk space for it: while n recomputes of the same range are pending within the grace period, the rollup occupies (n + 1) times its swept size, and the sweep itself briefly needs more until CrateDB has merged the deleted rows away. Each recompute adds one full version of the range; a newer one does not replace a pending older one.

After a Restore: Reconcile the Rollups​

A rollup archive keeps its aggregated windows together with a small table that says which generation of a window is the valid one (the generation map). A dump taken while a recompute runs, or a partial restore, can leave rows and map out of step: a map entry without rows, rows above the generation the map selects, a watermark ahead of the rows, or a missing map. The restore therefore reconciles every tenant that has rollups:

  1. The tenant is marked as restore reconcile pending. While the mark is set, the platform does not aggregate, recompute or sweep the rollups of the tenant, so nothing changes under the check.
  2. The rollups are validated (read only: counts and minimum/maximum, no rows are exported).
  3. A consistent restore needs nothing more; the mark is cleared and the restore result reports ok.
  4. Otherwise the repair runs: it creates a missing map, deletes rows above the selected generation, recomputes only the ranges that have no rows and rewinds a watermark that is ahead of the rows. The forward aggregation fills the rest.
  5. The mark is cleared only when the tenant validates ok afterwards. A repair step that fails leaves the mark set and is named in the result (failedStep); the restore itself has succeeded.

The restore result lists, per rollup, the findings before, the repair steps with their status, and the findings after (rollupReconcile).

What the validation counts as inconsistent: a pointer entry of a rollup that holds no row of its generation is reported only where a source of the rollup holds rows in that range. A recompute or backfill over a range the source is empty in correctly leaves such an entry, and a healthy tenant (and its dump) can contain it, so it is not a finding. A source that is itself a rollup counts only the rows that are live under its own pointer.

The archives of a restore run in dependency order: every source before the rollups that read it. A rollup can only be activated while its source is activated, so a source that was disabled in the backup but has rollups stays activated, with the marker set, until those rollups are restored, and is disabled again at the end.

A rollup that cannot be checked is never reported as consistent. The validation lists it as not checked, with the cause and a reason, and a report with such a rollup is not ok:

CauseMeaningReport and marker
NoLiveTableThe rollup is activated (or failed) but has no table. Restore it again or activate it, then validate.Not ok; the marker stays set
SourceMissingA source archive of the rollup does not exist or has no table, so the watermark cannot be checked.Not ok; the marker stays set
NeverActivatedThe rollup was never activated and has no data, so nothing can be inconsistent.Listed as information only; the report stays ok and the marker is cleared
DisabledThe rollup is disabled and has no table (for example a rollup that was already disabled in the backed-up tenant). It is neither aggregated nor read.Listed as information only; the report stays ok and the marker is cleared

RepairRollups skips rollups that could not be checked and says so; it never turns a missing table into an empty one. An archive that failed to restore also keeps the marker set, whatever the validation says. ValidateRollups --failOnFindings and RepairRollups --wait exit with code -5 while a rollup is inconsistent or not checked (informational entries do not count).

With restore --wait the outcome is read from the finished job: the command exits with code -5 when an archive failed to restore or a rollup could not be checked in a blocking way, and names them, for example Tenant 't' (database 'db') restored with 2 failed archive(s): <id1>, <id2>; 1 rollup(s) not checked: <id> [ArchiveFailed]. The tenant is not fully restored. A rollup whose archive failed is reported with the cause ArchiveFailed. A clean restore exits with 0; without --wait the outcome is not read.

Deleting a tenant removes everything of this feature in CrateDB: the archive tables with their generation map, recompute staging and sweep records, the tenant's marker and its repair requests. A tenant created again under the same id therefore starts without a marker.

If a tenant stays marked, or you want to check a tenant at any time, run the same steps by hand. All of them are idempotent; repeating them is safe.

Stepocto-cliMCP toolREST (asset repository)
Validate (read only)ValidateRollups with --failOnFindings (-ff) to exit with code -5 on findingsvalidate_rollupsGET {tenantId}/v1/streamdata/rollups/validate
RepairRepairRollups: a dry run that lists the steps by default, --apply requests the repair, --wait polls it (every 5 seconds, up to 4 hours), -y skips the confirmationrepair_rollups (dry run by default)POST {tenantId}/v1/streamdata/rollups/repair with dryRun (default true); dryRun=false answers 202 with the location of the request
Status of a repair requestGetRollupRepairStatus with -rid <requestId>get_rollup_repair_statusGET {tenantId}/v1/streamdata/rollups/repair/<requestId>
# After a restore: check, look at the plan, apply and wait
octo-cli -c ValidateRollups
octo-cli -c RepairRollups
octo-cli -c RepairRollups --apply --wait

An applied repair is a request that the service executes in the background; it keeps running when the command ends. A second --apply while a repair is active returns the active request. RepairRollups --wait exits with code -5 when the repair has failed, and GetRollupRepairStatus --failOnFailed (-ff) exits with code -5 when the request has failed; without the flag it exits with 0. A request ends as Done or Failed; its final report lists every step and the validation after the repair.

Backup & Restore Workflow​

Regular Backup Strategy​

#!/bin/bash
# Daily backup script example

DATE=$(date +%Y_%m_%d_%H_%M)
TENANT_ID="sbeg"
BACKUP_DIR="/backups"
BACKUP_FILE="${BACKUP_DIR}/mongodb-backup-${TENANT_ID}-${DATE}.tar.gz"

# Create backup
octo-cli -c dump -tid ${TENANT_ID} -f ${BACKUP_FILE}

# Verify backup was created
if [ -f "${BACKUP_FILE}" ]; then
echo "Backup created successfully: ${BACKUP_FILE}"
# Optional: Upload to cloud storage, notify administrators, etc.
else
echo "ERROR: Backup failed for tenant ${TENANT_ID}"
exit 1
fi

Disaster Recovery Process​

# 1. Stop application services (if needed)
# systemctl stop octo-mesh-service

# 2. Restore from latest backup
octo-cli -c restore -tid production -db production-db -f /backups/latest-backup.tar.gz -w

# 3. Verify restoration
# Check entity counts, run validation queries, etc.

# 4. Restart services
# systemctl start octo-mesh-service

Best Practices​

Backup Strategy​

  • Regular Schedule: Implement automated daily or hourly backups based on data criticality
  • Retention Policy: Keep multiple backup versions (daily for 30 days, weekly for 12 weeks, monthly for 12 months)
  • Offsite Storage: Store backups in multiple locations (local, cloud, remote datacenter)
  • Validation: Periodically test backup integrity by performing test restores

Backup Naming​

  • Consistent Format: Use standardized naming with timestamps: mongodb-backup-{tenant}-{YYYY_MM_DD_HH_MM}.tar.gz
  • Descriptive Names: Include tenant ID and environment information
  • Version Control: Maintain backup catalogs with metadata about each backup

Restore Planning​

  • Test Environment: Always test restore procedures in non-production environments first
  • Downtime Planning: Schedule restore operations during maintenance windows
  • Verification Steps: Prepare validation queries to confirm restore success
  • Rollback Plan: Maintain current backup before performing restore operations

Security Considerations​

  • Access Control: Restrict backup and restore operations to authorized personnel only. They need the tenant role TenantManagement, and a backup contains all data of the tenant regardless of data permissions
  • Encryption: Encrypt backup files at rest and in transit
  • Audit Trail: Log all backup and restore operations for compliance
  • Network Security: Use secure channels for backup file transfers
  • Secret Attributes: Backups contain Secret attributes in encrypted form. A restore keeps them encrypted. Into another environment, values with an unknown key id read as not set (keyMissing) and must be re-entered, or become readable when the source key is added to the key ring. Disaster recovery needs the dump and the key ring backup (see Restore across environments)

Monitoring & Verification​

Backup Verification​

# Check backup file size and integrity
ls -lh ./backup.tar.gz
tar -tzf ./backup.tar.gz | head -10

# Verify backup contains expected collections
# (Restore to test environment and validate)

Restore Verification​

# After restore, verify tenant is accessible
octo-cli -c query -tid sbeg -q "{ \"ckTypeId\": \"System/Entity\" }" -l 5

# Check entity counts match expectations
# Verify critical business data is present
# Test application functionality
warning

Critical Safety Notice: Restore operations completely replace existing tenant data. Always create a current backup before performing restore operations in production environments.

tip

Use the -w (watch) flag during restore operations to monitor progress and identify potential issues early in the process.

Troubleshooting​

Common Issues​

  • Insufficient Disk Space: Ensure adequate space for backup files and extraction
  • Permission Errors: Verify file system permissions for backup directories
  • Network Timeouts: For large backups, ensure stable network connections
  • Version Compatibility: Ensure backup compatibility with current OctoMesh version

Recovery Scenarios​

  • Partial Data Loss: Use selective restore with specific date ranges
  • Corruption Recovery: Restore from the most recent clean backup
  • Migration Support: Use backup/restore for tenant migration between environments