New to Kestra?
Use blueprints to kickstart your first workflows.
Restore Kestra flows, namespace files, and key-value stores from a GitLab repo with a GitOps backup and recovery workflow driven by the GitLab API.
Treat GitLab as the single source of truth for your entire Kestra environment. This blueprint restores and synchronizes flows, namespace files, and key-value (KV) store entries directly from a GitLab repository, solving the problem of rebuilding a Kestra instance after a migration, outage, or environment reset. Instead of clicking through the UI to recreate workflows and configuration, you point this flow at a branch and let it pull everything back into the right namespaces, declaratively and repeatably.
branch_target input lets you pick which GitLab branch to restore from
(main or kestra), so you can promote between environments safely.get_flows_targets and git_target call the GitLab REST API with
io.kestra.plugin.core.http.Request to list the subfolders under
_flows and _files, using {{ secret('GITLAB_API_TOKEN') }} for auth.for_each_flows_folder iterates those folders and runs
io.kestra.plugin.git.SyncFlows, mapping each _flows/<name> directory
into a matching targetNamespace.for_each_files_folder does the same with
io.kestra.plugin.git.SyncNamespaceFiles, restoring namespace files from
each _files/<name> directory.fetch_kv downloads _kv/kvStore.json, then nested
for_each_namespace_store and for_each_key loops PUT each key back
into the Kestra KV API, preserving STRING typing on the value.GitLab can host the source of truth and trigger CI, but it cannot reconcile
that state into a running Kestra instance, fan out across an unknown set of
namespace folders, or retry a partial restore. Kestra adds event and
schedule triggers, per-task retries, full execution lineage over every
SyncFlows, SyncNamespaceFiles, and KV write, and a declarative YAML
definition that is itself versioned in the same GitLab repo it restores.
_flows, _files, and _kv folders.vars.your_project_id.kv('kestra_local_uri') for KV writes.GITLAB_API_TOKEN: GitLab access token for the REST API and Git pulls.KESTRA_API_TOKEN: authorization header for the Kestra KV API.GITLAB_API_TOKEN and KESTRA_API_TOKEN secrets.vars.your_git_repository and vars.your_project_id to your repo.kestra_local_uri KV value to your Kestra API endpoint.branch_target to restore from.