Treat Git as the single source of truth for your entire Kestra instance. This blueprint discovers every namespace, then exports its flows, namespace files, and key-value (KV) store entries into a GitLab repository on a recurring schedule. It solves a real operational gap: Kestra resources created or edited through the UI and API live in the platform's database, so without a versioned export you have no audit trail, no peer-reviewable history, and no clean disaster-recovery path. With this flow, every namespace lands in Git as structured, diffable files, and stable states can be promoted through GitLab releases and merge requests.
How it works
- The
get_namespaces task runs a io.kestra.plugin.core.flow.Subflow (get-all-namespaces) to enumerate every namespace dynamically.
loop_namespaces, a io.kestra.plugin.core.flow.Loop with concurrencyLimit: 1, iterates over each namespace and runs a Parallel block per namespace.
- Inside it, the
kv_storing branch calls the Kestra API via io.kestra.plugin.core.http.Request to list KV keys (get_keys) and fetch each value (retrieve_values).
- The
pushes branch commits resources to GitLab: push_files (io.kestra.plugin.git.PushNamespaceFiles) under _files/<namespace> and push_flows (io.kestra.plugin.git.PushFlows) under _flows/<namespace>.
set_wd (WorkingDirectory) assembles a kvStore.json from the retrieved KV pairs and stages it with io.kestra.plugin.core.namespace.UploadFiles.
push_kv commits the KV export with another PushNamespaceFiles, then delete_stored_kv (DeleteFiles) cleans up the temporary namespace files.
- When
make_new_release is set, make_release POSTs to the GitLab Releases API; when release_name equals Latest, create_pull_request opens a merge request from the kestra branch into main.
- The
weekly_saves io.kestra.plugin.core.trigger.Schedule trigger runs the whole export on cron 0 0 7,14,21,28 * *.
What you get
- A complete, versioned export of all namespaces: flows, files, and KV pairs.
- GitLab as the canonical, diffable source of truth for your instance.
- Optional tagged releases to snapshot known-good states.
- Optional merge requests to promote the latest export into
main.
- A recurring schedule so backups happen without manual effort.
Who it's for
- Platform administrators safeguarding a shared Kestra instance.
- DevOps and infrastructure engineers building GitOps governance.
- Teams needing disaster recovery and environment replication.
Why orchestrate this with Kestra
GitLab can store and review your exports, but its own CI scheduler cannot reach into Kestra to enumerate namespaces, read the KV store, and serialize flows. Kestra drives that export end to end: event-aware Schedule triggers, automatic retries on transient API or Git failures, full execution lineage across the parallel and per-namespace branches, and everything declared in version-controlled YAML. You get the backup orchestration GitLab pipelines cannot express on their own.
Prerequisites
- A reachable Kestra instance (set
kestra_local_uri).
- A GitLab repository (
your_git_repository) and project ID (your_project_id).
- The
get-all-namespaces subflow available in your namespace.
Secrets
GITLAB_API_TOKEN: authenticates the Git pushes, releases, and merge requests.
KESTRA_API_TOKEN: authorizes the Kestra API calls that list and read KV pairs.
Quick start
- Add the
GITLAB_API_TOKEN and KESTRA_API_TOKEN secrets.
- Set the
your_git_repository, kestra_local_uri, and your_project_id variables.
- Confirm the
get-all-namespaces subflow exists.
- Run once with
make_new_release set to false to validate the export.
- Let the
weekly_saves schedule take over, or trigger releases as needed.
How to extend
- Adjust the
weekly_saves cron for daily or nightly backups.
- Filter to specific namespaces by editing the
Loop values.
- Add a Slack or email notification on completion or failure.
- Pair with a restore flow to close the full backup and recovery loop.
Links