Introducing a new way to review your PRs.

Read the announcement

gotempsh / temps

AI-native open-source alternative to Vercel + Sentry + PostHog + Pingdom + Resend + E2B. 440+ CLI operations with drop-in skills for Claude Code, Codex & OpenCode — deployments, analytics, session replay, error tracking, OpenTelemetry, email, sandboxes & AI gateway in one self-hosted Rust binary.

View on GitHub

25 documents · Updated Oct 21, 2026

docs / managed-services-and-data-import

Managed services and data import

Managed services give hosted applications database and storage resources that Temps can run and connect to. The data-import feature copies a database from an external, publicly reachable server into one of these managed services while protecting the target, limiting the transfer, and giving operators a durable view of progress and results. See Projects and environments for service links, Deployment orchestration for workload coordination, Domains and networking for service exposure, and Backup and recovery for the separate backup-based restore flow.

Managed service providers

Managed service providers represent the engine-specific rules for a service while the platform supplies one common operating model. A provider can expose data import only when its service can receive data in the current topology and runtime state. The current import-capable engines are PostgreSQL, MariaDB, MongoDB, and Redis; clustered or worker-hosted services are not eligible for this workflow.

References: crates/…/mod.rs• L1210-1216 crates/…/mod.rs• L1840-1854 crates/…/service.rs• L201-238

Provider import contracts

Each provider describes the source connection forms it accepts, the target naming rules, whether the transfer is all-or-nothing, and the kind of data it counts after import. The shared service uses this contract to present the form and to keep the common flow consistent across engines.

References: crates/…/mod.rs• L55-76 crates/…/data_import.rs• L294-329 crates/…/data_import.rs• L180-221 crates/…/data_import.rs• L214-277 crates/…/data_import.rs• L333-379

Data-import workflow

An import starts with a source connection string and a target database name. Temps checks that the service and source are usable, records a run, and returns before the copy finishes so the operator can follow the run through its later phases.

The main flow is:

flowchart LR
    A[Select managed service] --> B[Read import availability]
    B --> C[Enter external source and target]
    C --> D[Validate source and target]
    D --> E[Inspect and prepare target]
    E --> F[Run bounded transfer]
    F --> G[Verify target]
    G --> H[Show result and history]

References: crates/…/service.rs• L201-357 web/…/ServiceDataImport.tsx• L28-171

Source selection

The operator selects a managed service and enters a connection string for the external database. The service-specific import contract supplies the accepted schemes, example, and safe option list. The source must name the database to copy, and the target must be a valid non-system database name for the selected engine.

Temps checks source hosts before it starts the transfer. It rejects local, private, and other unsafe destinations, then pins accepted host names to checked addresses so a later DNS change cannot redirect the helper to a different address. The raw connection string is used only for the transfer; stored, logged, audited, and returned forms mask credentials.

References: web/…/DataImportForm.tsx• L168-232 crates/…/source.rs• L12-19 crates/…/source.rs• L186-287 crates/…/source.rs• L452-493 crates/…/data_import_handlers.rs• L156-186

Target preparation

The target is the logical database inside the managed service. Temps inspects it before copying and applies one of three policies: create a missing target, use an existing empty target, or recreate an existing target only when the operator explicitly requests replacement.

Replacement is destructive. The request must repeat the target name and pass the platform’s sensitive-action check. An import and a restore cannot write to the same service at the same time, and only one import can write to a given target database while it is running.

References: crates/…/mod.rs• L78-126 crates/…/service.rs• L255-313 crates/…/data_import_handlers.rs• L396-475 crates/…/m20261008_000001_create_service_data_imports.rs• L25-61

Transfer runner

The transfer runs in a short-lived helper attached to the managed service’s network. The helper streams the source dump into the target instead of writing the full transfer to disk, and its time limit bounds how long the copy can run. The runner keeps source-side and target-side failures distinct so an operator can act on the correct system.

The helper has no extra capabilities and receives secrets through its run-time environment. Its output is shortened and scrubbed before it becomes part of the run record. Cancellation and restart handling stop the helper before the run releases its target lock.

References: crates/…/runner.rs• L4-19 crates/…/runner.rs• L86-117 crates/…/runner.rs• L249-380 crates/…/runner.rs• L438-566 crates/…/service.rs• L1296-1317

Import execution

After the request passes its checks, a background job records the run as active and moves through target preparation, data transfer, and result verification. A successful run records the target object count and size when the provider can measure them. A failed non-atomic transfer can leave partial data, while an atomic transfer leaves no imported data from the failed copy.

sequenceDiagram
    participant O as Operator
    participant C as Control plane
    participant S as Managed service
    participant R as Import runner
    participant X as External database

    O->>C: Start import
    C->>S: Inspect and prepare target
    C->>R: Start bounded helper
    R->>X: Read source dump
    R->>S: Stream data into target
    R-->>C: Transfer outcome and scrubbed output
    C->>S: Verify target
    C-->>O: Persisted run result

References: crates/…/service.rs• L14-20 crates/…/service.rs• L979-1152 crates/…/service.rs• L1261-1294 crates/…/data_import.rs• L331-392

Operator progress tracking

The console treats availability and run state as operator-facing data. It keeps the import page visible even when a service cannot accept an import, explains the reason, and shows prior runs without exposing source credentials. The run page presents the current phase, status, timing, source and target summary, result counts, cancellation state, and scrubbed transfer output.

Active runs are polled at a short interval. Operators can request cancellation while the copy is still cancellable, then continue polling until the background job settles. A server restart changes an orphaned active run to interrupted only after its helper is fenced; the run remains visible so the operator knows whether to retry.

References: web/…/import-state.ts• L29-74 web/…/DataImportRunsCard.tsx• L57-149 web/…/ServiceDataImportRun.tsx• L59-175 web/…/ServiceDataImportRun.tsx• L264-315 crates/…/service.rs• L471-567

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep provider import rules aligned with the availability response and the console form. The same source schemes, target limits, object name, and atomicity affect both validation and operator guidance.
  • Preserve the target-name contract used by project environments. A target that does not match the linked environment’s managed name will not receive that environment’s data.
  • Keep the active-run lock and restore conflict checks aligned with cancellation and restart fencing. Releasing either lock before the helper stops can allow two writers to race.
  • Keep masked source data and scrubbed helper output consistent across run records, audit events, API responses, and console details.
  • Keep run status and phase values synchronized across persistence, API responses, and progress labels. Unknown or stale values can make a live run look finished or hide its failure point.

Important failure modes

TriggerConsequenceGuard
Source host resolves to a private, loopback, or metadata addressThe import is refused before a helper startsSource validation checks every host and pins accepted names
Target already contains data without replacementNo run starts and existing data stays unchangedTarget inspection requires an empty target or explicit replacement confirmation
Restore or another import is active for the same write scopeThe request receives a conflict instead of starting a second writerService locking and the per-target active-run constraint serialize writes
Non-atomic transfer fails after writing part of the dataThe target can contain partial dataThe run records this outcome and advises a replacement import
Helper timeout, cancellation, or process restart occursThe run does not finish normally and may require a retryThe runner is stopped or fenced before the run settles and releases its lock
Source credentials appear in tool outputSensitive connection data could reach logs or the consoleMasked source values and bounded, scrubbed helper output are persisted

Key files

FileWhy to read it
crates/…/service.rsEnd-to-end import coordination, target checks, run state, cancellation, and restart recovery
crates/…/mod.rsShared provider contract and target preparation model
crates/…/source.rsSource parsing, host checks, address pinning, and secret handling
crates/…/runner.rsHelper lifecycle, streaming transfer, timeouts, and fencing
crates/…/data_import_handlers.rsAvailability, start, history, run detail, and cancellation API surface
crates/…/service_data_imports.rsDurable run record and its relationship to managed services and users
web/…/ServiceDataImport.tsxOperator entry point for availability, source selection, and import history
web/…/ServiceDataImportRun.tsxOperator view of phases, outcome, details, and transfer output
web/…/import-state.tsShared console rules for statuses, phases, polling, and form behavior