Skip to content
  • Documentation
  • Tutorials
  • Blogs
  • Product

What's on this Page

  • Architecture and persisted data
  • Automatic restarts
    • Kubernetes
    • Linux and Windows servers
    • Impact of a restart
    • Executions interrupted by a controller restart
    • Maintenance window
  • Failure scenarios
    • Database volume full or lost
    • Controller volume full or lost
  • Backups
    • Strategy
    • Backup image
    • Prerequisites
    • Backup CronJobs of the Helm chart
  • Restore procedure
    • 1. Stop the controller
    • 2. Start a restore pod
    • 3. Restore the controller volume
    • 4. Restore the database
    • 5. Start the controller
  • Summary
  1. Step
  2. Admin guide
  3. Maintenance
  4. Disaster Recovery
This article references one of our previous releases, click here to go to our latest version instead.

Disaster Recovery

What's on this Page

  • Architecture and persisted data
  • Automatic restarts
    • Kubernetes
    • Linux and Windows servers
    • Impact of a restart
    • Executions interrupted by a controller restart
    • Maintenance window
  • Failure scenarios
    • Database volume full or lost
    • Controller volume full or lost
  • Backups
    • Strategy
    • Backup image
    • Prerequisites
    • Backup CronJobs of the Helm chart
  • Restore procedure
    • 1. Stop the controller
    • 2. Start a restore pod
    • 3. Restore the controller volume
    • 4. Restore the database
    • 5. Start the controller
  • Summary

This page describes the disaster recovery of a Step instance: what happens when a component restarts, what to do when the database or the controller runs out of disk space or loses its data, how to back up Step and how to restore it.

The behavior of Step described on this page applies to every installation. The procedures are given for an instance deployed on Kubernetes with the Step Helm chart, with notes for the installations on Linux and Windows servers. For the backup and restore commands of the database outside of Kubernetes, see Backup & Restore.

Architecture and persisted data

A Step instance is made of a controller, agents and a database (MongoDB, or PostgreSQL). With the Step Helm chart, each of them runs as a StatefulSet. The following components hold data:

Component Persistent volume (PVC) Content Loss impact
MongoDB datadir-mongodb-0, mounted under /bitnami/mongodb All Step entities (plans, keywords, parameters, users, projects, settings…), executions, reports, measurements and time series. See the data model Critical
PostgreSQL (alternative to MongoDB) data-postgresql-0 Same as MongoDB: one table per collection Critical
Controller <namespace>-<controller>-data-<controller>-0, mounted under /home/controller/data The files of the resources (automation package archives, libraries, datasets, keyword files, attachments), the automation package cache, the scripts Critical for the resources, the rest can be rebuilt
Agents none Stateless None, the agent re-registers to the controller on startup

<controller> is enterprise-controller for Step Enterprise and controller for Step Community. On a Linux or Windows server, the controller data is the data folder of the controller installation.

The database and the controller volume reference each other: a file resource entry in the database points to a file on the controller volume. Always back up and restore both of them, from the same point in time.

Automatic restarts

Kubernetes

All Step StatefulSets use restartPolicy: Always: Kubernetes restarts a container whenever its process exits, for instance after a crash or when the container is killed for exceeding its memory limit (OOMKilled).

By default, the chart does not configure any liveness or readiness probes (controller.probes, agent.pools[].probes are empty and mongodb.livenessProbe.enabled / mongodb.readinessProbe.enabled are false). A process that hangs without exiting is therefore not restarted automatically. To have Kubernetes detect and restart a non-responding controller or agent, enable the probes in your values:

controller:
  probes:
    startupProbe:
      httpGet:
        path: /
        port: gui
      failureThreshold: 60
      periodSeconds: 10
    livenessProbe:
      httpGet:
        path: /
        port: gui
      initialDelaySeconds: 10
      periodSeconds: 30
    readinessProbe:
      httpGet:
        path: /
        port: gui
      initialDelaySeconds: 10
      periodSeconds: 30

agent:
  pools:
  - # ... existing pool configuration
    probes:
      startupProbe:
        httpGet:
          path: /running
          port: agent-port
        failureThreshold: 60
        periodSeconds: 10
      livenessProbe:
        httpGet:
          path: /running
          port: agent-port
        initialDelaySeconds: 10
        periodSeconds: 10
      readinessProbe:
        httpGet:
          path: /registered
          port: agent-port
        initialDelaySeconds: 10
        periodSeconds: 10

The /registered readiness endpoint is not yet implemented by the Node.js agent: only configure the startup and liveness probes for Node.js agent pools.

Linux and Windows servers

When the controller and the agents are installed as services, the service manager restarts them:

  • Linux (systemd): set Restart=on-failure in the service unit, as shown in the controller installation. Without a Restart= setting, systemd does not restart a process that exits.
  • Windows (nssm): nssm restarts the application when it exits, by default (tab Exit actions).

As with Kubernetes, a service manager only restarts a process that exits, not a process that hangs.

Impact of a restart

  • Agent: the keywords running on the agent at that time fail with an error, which is handled as defined in your plan (for instance retried by a RetryIfFails control, or stopping the Sequence unless ContinueOnError is set), and the execution continues accordingly. Once restarted, the agent registers to the controller immediately and receives new keywords.
  • Database: the controller loses its database connection. Running executions are likely to fail, and the controller reconnects once the database is back. On Kubernetes, the chart configures a preStop hook that waits for the ongoing database operations to complete before the database shuts down (termination grace period: 180 seconds).
  • Controller: the running executions may be interrupted, see below.

Executions interrupted by a controller restart

An execution runs inside the controller process:

  • When the controller is stopped gracefully, it stops scheduling new executions and waits for the running executions to complete, without timeout. Make sure the platform gives it enough time: on Kubernetes, the controller is killed after controller.terminationGracePeriodSeconds (120 seconds by default); with systemd after TimeoutStopSec (90 seconds by default); with nssm after the timeouts of the Shutdown tab. Increase these values if your executions last longer.
  • When the controller crashes or is killed, its running executions stop immediately. The execution reports remain available up to that point: only the results of the steps in progress are lost.

At the next startup, the controller detects the executions that were still running (status other than ENDED) and started since its previous startup. It logs the following warning, and sets their status to ENDED with the restart time as end time:

Found 2 executions in an inconsistent state. The system might not have been shutdown cleanly or crashed. Starting recovery...

Such executions are incomplete:

  • Their result and their report reflect the state at the time of the interruption: the steps that were running are never completed.
  • They cannot be resumed. Restart starts a new execution of the whole plan with the same parameters, and the selection of test cases to relaunch is based on incomplete statuses.
  • An execution of an automation package in an isolated context can no longer be restarted once the housekeeping has removed its temporary automation package.

To limit the impact:

  • Do not restart the controller while executions are running: plan the upgrades (helm upgrade), node maintenances (kubectl drain) and cluster upgrades in a maintenance window.
  • Make sure the controller is not killed for lack of memory: on Kubernetes, set its memory request equal to its limit and keep enough headroom for the JVM, see the requirements.
  • After an unplanned restart, trigger the affected plans again if required, from Step or from your CI/CD pipeline. Scheduled executions, for instance of synthetic monitoring, simply run again at their next schedule.

Maintenance window

To prepare a maintenance (upgrade, restart, backup or cleanup), avoid new executions and inform the users:

  1. Disable the scheduler: in Admin > Settings > Scheduler, disable the scheduler. The schedules are no longer executed, in all the projects, until the scheduler is enabled again. See Schedules global settings.
  2. Set a maintenance message (Enterprise): in the Maintenance page of the admin view, enter a message and enable it, to inform the users. Users need the maintenance-message-write right, see role management.
  3. Wait for the running executions to complete (Executions list), or stop them.

After the maintenance, enable the scheduler again and disable the maintenance message.

Failure scenarios

Database volume full or lost

Symptoms: MongoDB (or PostgreSQL) stops accepting writes or crashes when its volume is full. The controller cannot start, or executions fail with database errors.

Prevention:

  • Size the database volume for your retention, see requirements.
  • Enable the housekeeping to delete old executions, reports and time series automatically.
  • Monitor the usage of the PVC (for instance with the kubelet_volume_stats_used_bytes metric).

Recovery when the volume is full:

  1. Expand the PVC, if its StorageClass has allowVolumeExpansion: true:
    kubectl -n <namespace> patch pvc datadir-mongodb-0 -p '{"spec":{"resources":{"requests":{"storage":"60Gi"}}}}'
    
    The volume size in the Helm values (mongodb.persistence.size) only applies when the PVC is created: the volume claim templates of a StatefulSet cannot be changed afterwards.
  2. Once the database is up again, reduce the data with the housekeeping. MongoDB does not give the freed space back to the file system, but reuses it for new data.

If the volume cannot be expanded, Step remains usable as long as the database is running: avoid new executions as described in Maintenance window, and run the housekeeping (or a manual purge) to free space for new data. If the database has already stopped because its disk is completely full, it cannot start again until some space is freed on its volume: in that case, expand the volume or restore the database.

Recovery when the data is lost or corrupted: restore the database and the controller volume from the latest backups, following the restore procedure.

Controller volume full or lost

Symptoms: uploads and automation package deployments fail, attachments cannot be stored, or executions fail because a resource file is missing.

Recovery when the volume is full:

  1. Expand the PVC as described above (PVC <namespace>-<controller>-data-<controller>-0), or free some space. The temporary and cache folders (tmp, temp, AP_cache, temp_isolated_ap) are rebuilt by the controller, and the execution attachments (attachment, streamedAttachment) are removed with their executions by the housekeeping.
  2. Restart the controller if needed.

Recovery when the data is lost or corrupted: restore the controller volume and the database from the same backup point in time, following the restore procedure.

If the encryption manager is enabled, its key pair must survive the loss of the controller pod: set encryption.manager.keypair.folder to a folder of the controller volume (for instance /home/controller/data/encryptionManager) and back it up. Without the key pair, the encrypted values cannot be recovered.

Backups

Strategy

The Step Helm chart can create backup CronJobs for the controller volume and for MongoDB. Two kinds of backups are described:

  • Partial backups (recommended, daily): the configuration of Step only: plans, keywords, parameters, resources, automation packages, users, projects, settings… The execution history (executions, reports, measurements, time series) and the temporary files are excluded. They run while Step is up, and are small and fast to restore.
  • Full backups (optional): the whole controller volume and the whole MongoDB data folder, including the execution history. They copy the files of the volumes as they are: take them in a maintenance window, with the controller stopped, so that the data is not modified during the copy.

The examples below send the archives with ssh to a backup host, keep the latest historyLimit archives and delete the older ones. Adapt the script to your backup target (object storage, NFS share…).

Backup image

The backup jobs need an image containing the backup tools. This image is not provided by Exense: build it and push it to a registry your cluster can pull from. The following Dockerfile contains the tools used by all the examples of this page (bash, tar, gzip, ssh, the MongoDB Database Tools and the PostgreSQL client):

FROM debian:trixie-slim

# MongoDB Database Tools (mongodump / mongorestore), Debian 13 packages exist from version 100.20.1
ARG MONGODB_TOOLS_VERSION=100.20.1

RUN apt-get update \
 && apt-get install -y --no-install-recommends \
      bash ca-certificates curl gzip tar openssh-client postgresql-client-17 \
 && curl -fsSL -o /tmp/mongodb-database-tools.deb \
      "https://fastdl.mongodb.org/tools/db/mongodb-database-tools-debian13-x86_64-${MONGODB_TOOLS_VERSION}.deb" \
 && apt-get install -y --no-install-recommends /tmp/mongodb-database-tools.deb \
 && rm /tmp/mongodb-database-tools.deb \
 && apt-get purge -y curl && apt-get autoremove -y \
 && rm -rf /var/lib/apt/lists/*
docker build -t registry.example.com/step-backup:1.0.0 .
docker push registry.example.com/step-backup:1.0.0

Notes:

  • The PostgreSQL client must be of the same or a newer major version than the PostgreSQL server: the client 17 of Debian 13 works with the PostgreSQL 15 server of the default chart values. Use pg_restore from the same image as pg_dump, as an archive cannot be read by an older client.
  • MongoDB provides the Debian packages of the Database Tools for x86_64 only: the image must run on x86_64 nodes.
  • The jobs run as root, so that they can read all the files of the volumes and preserve their ownership on restore. If your cluster enforces a restricted Pod Security Standard, run them as the user owning the files instead (1001 for MongoDB).
  • For your private registry, set imagePullSecrets in the Helm values.

Prerequisites

Create a Secret holding the private SSH key authorized on the backup host:

kubectl -n <namespace> create secret generic step-backup-ssh-key --from-file=id_backup=./id_backup

Backup CronJobs of the Helm chart

The chart creates one CronJob per entry of controller.backups and of mongodb.backups, named <controller>-<name>-backup and mongodb-<name>-backup. Each entry supports the following keys:

Key Description Default
schedule Cron expression of the job
suspend Suspend the scheduling of the job
timeZone Time zone of the schedule Europe/Zurich
concurrencyPolicy CronJob concurrency policy Forbid
startingDeadlineSeconds Deadline to start a missed job 30
successfulJobsHistoryLimit / failedJobsHistoryLimit Number of finished jobs to keep 1
image Backup image, see Backup image
command / args Command of the backup container. args are evaluated as templates and can reference the Helm values
extraEnvVars Environment variables of the backup container
extraVolumes / extraVolumeMounts Additional volumes, for instance the SSH key
existingClaim PVC mounted as volume datadir, at the data path of the component
resources, nodeSelector, affinity Scheduling settings of the job

historyLimit in the examples is not a key of the chart: it is only read by the example scripts, to rotate the archives.

The controller and MongoDB volumes are ReadWriteOnce: a job mounting one of them while its pod is running must run on the same node. This is the role of the podAffinity of the examples.

Partial backups

The following values back up the controller volume without the temporary files and the execution attachments, and the MongoDB database without the execution history. mongodump connects to MongoDB over the network, so this job does not mount the MongoDB volume.

controller:
  backups:
    partial:
      suspend: false
      schedule: "00 02 * * *"
      timeZone: "Europe/Zurich"
      historyLimit: 7
      image: "registry.example.com/step-backup:1.0.0"
      extraEnvVars:
      - name: MY_POD_NAMESPACE
        valueFrom:
          fieldRef:
            fieldPath: metadata.namespace
      - name: SSH_OPTS
        value: "-i /etc/ssh-key/id_backup -o StrictHostKeyChecking=accept-new"
      - name: BKP_USER
        value: "backup"
      - name: BKP_HOST
        value: "backup.example.com"
      command: ["/bin/bash"]
      args:
      - "-c"
      - "
        set -eo pipefail;
        DIR=${MY_POD_NAMESPACE}/controller/partial;
        ARCHIVE=$(date +%Y%m%d-%H%M)_controller-data.tar.gz;
        ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"mkdir -p ${DIR}\";
        tar --warning=no-file-changed --exclude={tmp,temp,attachment,node_modules,videos,dumps,pdftest,AP_cache,streamedAttachment,temp_isolated_ap} -C {{ .Values.controller.persistence.pvc.data.mountPath }} -zcf - . | ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"cat > ${DIR}/${ARCHIVE}\" || [ $? -eq 1 ];
        ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"cd ${DIR} && ls -tp | grep -v / | tail -n +{{ add1 .Values.controller.backups.partial.historyLimit }} | xargs -d '\\n' -r rm --\";
        "
      resources:
        requests:
          cpu: 10m
          memory: 16Mi
        limits:
          cpu: 1000m
          memory: 1000Mi
      extraVolumeMounts:
      - name: ssh-key
        mountPath: /etc/ssh-key
      extraVolumes:
      - name: ssh-key
        secret:
          secretName: step-backup-ssh-key
          defaultMode: 0400
      existingClaim: '{{ $.Release.Namespace }}-{{ include "step.controller.component.name" $ }}-data-{{ include "step.controller.component.name" $ }}-0'
      affinity:
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app.kubernetes.io/instance
                operator: In
                values:
                - "{{ $.Release.Name }}"
              - key: app.kubernetes.io/component
                operator: In
                values:
                - '{{ include "step.controller.component.name" $ }}'
            topologyKey: kubernetes.io/hostname

mongodb:
  backups:
    partial:
      suspend: false
      schedule: "00 02 * * *"
      timeZone: "Europe/Zurich"
      historyLimit: 7
      image: "registry.example.com/step-backup:1.0.0"
      extraEnvVars:
      - name: MY_POD_NAMESPACE
        valueFrom:
          fieldRef:
            fieldPath: metadata.namespace
      - name: SSH_OPTS
        value: "-i /etc/ssh-key/id_backup -o StrictHostKeyChecking=accept-new"
      - name: BKP_USER
        value: "backup"
      - name: BKP_HOST
        value: "backup.example.com"
      - name: EXCLUDE_COLLECTIONS
        value: "--excludeCollection=executions --excludeCollection=reports --excludeCollection=measurements --excludeCollection=metricSamples --excludeCollection=views --excludeCollection=resolvedPlans --excludeCollection=streaming_resources --excludeCollection=agentProvisioningStatuses --excludeCollection=lastExecutionBeforeStatusChangeCache --excludeCollectionsWithPrefix=reportNodeTimeSeries --excludeCollectionsWithPrefix=timeseries"
      command: ["/bin/bash"]
      args:
      - "-c"
      - "
        set -eo pipefail;
        DIR=${MY_POD_NAMESPACE}/mongodb/partial;
        ARCHIVE=$(date +%Y%m%d-%H%M)_step-dump.gz;
        ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"mkdir -p ${DIR}\";
        mongodump --host={{ .Values.mongodb.fullnameOverride }} --port={{ .Values.mongodb.service.ports.mongodb }} --db=step ${EXCLUDE_COLLECTIONS} --gzip --archive | ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"cat > ${DIR}/${ARCHIVE}\";
        ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"cd ${DIR} && ls -tp | grep -v / | tail -n +{{ add1 .Values.mongodb.backups.partial.historyLimit }} | xargs -d '\\n' -r rm --\";
        "
      resources:
        requests:
          cpu: 10m
          memory: 16Mi
        limits:
          cpu: 1000m
          memory: 1000Mi
      extraVolumeMounts:
      - name: ssh-key
        mountPath: /etc/ssh-key
      extraVolumes:
      # mongodump connects over the network: an empty volume replaces the MongoDB volume
      - name: datadir
        emptyDir: {}
      - name: ssh-key
        secret:
          secretName: step-backup-ssh-key
          defaultMode: 0400

Notes:

  • tar exits with code 1 when a file changes while it is read, which is expected while the controller is running: the script accepts this code and fails on any other error.
  • If MongoDB authentication is enabled (mongodb.auth.enabled: true), pass the credentials to mongodump with --username, --password and --authenticationDatabase, read from the MongoDB Secret with extraEnvVars.

Partial backup with PostgreSQL

The chart has no backup CronJob template for PostgreSQL. Deploy the CronJob with commons.extraDeploy, which adds any manifest to the release. pg_dump connects to PostgreSQL over the network and excludes the tables of the execution history:

commons:
  extraDeploy: |
    apiVersion: batch/v1
    kind: CronJob
    metadata:
      name: postgresql-partial-backup
    spec:
      schedule: "00 02 * * *"
      timeZone: "Europe/Zurich"
      concurrencyPolicy: Forbid
      startingDeadlineSeconds: 30
      successfulJobsHistoryLimit: 1
      failedJobsHistoryLimit: 1
      jobTemplate:
        spec:
          template:
            spec:
              restartPolicy: OnFailure
              containers:
              - name: postgresql-partial-backup
                image: registry.example.com/step-backup:1.0.0
                env:
                - name: MY_POD_NAMESPACE
                  valueFrom:
                    fieldRef:
                      fieldPath: metadata.namespace
                - name: HISTORY_LIMIT
                  value: "7"
                - name: SSH_OPTS
                  value: "-i /etc/ssh-key/id_backup -o StrictHostKeyChecking=accept-new"
                - name: BKP_USER
                  value: "backup"
                - name: BKP_HOST
                  value: "backup.example.com"
                - name: PGHOST
                  value: "{{ .Values.postgresql.fullnameOverride }}"
                - name: PGUSER
                  value: "postgres"
                - name: PGDATABASE
                  value: "{{ .Values.postgresql.global.postgresql.auth.database }}"
                - name: PGPASSWORD
                  valueFrom:
                    secretKeyRef:
                      name: "{{ .Values.postgresql.fullnameOverride }}"
                      key: postgres-password
                command: ["/bin/bash", "-c"]
                args:
                - |
                  set -eo pipefail
                  DIR=${MY_POD_NAMESPACE}/postgresql/partial
                  ARCHIVE=$(date +%Y%m%d-%H%M)_step.dump
                  ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} "mkdir -p ${DIR}"
                  pg_dump --format=custom \
                    --exclude-table='"executions"' \
                    --exclude-table='"reports"' \
                    --exclude-table='"measurements"' \
                    --exclude-table='"metricSamples"' \
                    --exclude-table='"views"' \
                    --exclude-table='"resolvedPlans"' \
                    --exclude-table='"streaming_resources"' \
                    --exclude-table='"agentProvisioningStatuses"' \
                    --exclude-table='"lastExecutionBeforeStatusChangeCache"' \
                    --exclude-table='"reportNodeTimeSeries"' \
                    --exclude-table='"reportNodeTimeSeries_minute"' \
                    --exclude-table='"reportNodeTimeSeries_hour"' \
                    --exclude-table='"reportNodeTimeSeries_day"' \
                    --exclude-table='"reportNodeTimeSeries_week"' \
                    --exclude-table='timeseries*' \
                    | ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} "cat > ${DIR}/${ARCHIVE}"
                  ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} "cd ${DIR} && ls -tp | grep -v / | tail -n +$((HISTORY_LIMIT + 1)) | xargs -d '\n' -r rm --"
                volumeMounts:
                - name: ssh-key
                  mountPath: /etc/ssh-key
              volumes:
              - name: ssh-key
                secret:
                  secretName: step-backup-ssh-key
                  defaultMode: 0400    

Step creates one table per collection, named after the collection: the names are case-sensitive and must be quoted. The controller volume is backed up with the same controller.backups.partial values as with MongoDB.

Full backups

The following values define the full backups as suspended CronJobs: they are never scheduled, and serve as templates to run the full backups manually.

controller:
  backups:
    full:
      suspend: true
      schedule: "00 03 * * 0"
      historyLimit: 3
      image: "registry.example.com/step-backup:1.0.0"
      extraEnvVars:
      - name: MY_POD_NAMESPACE
        valueFrom:
          fieldRef:
            fieldPath: metadata.namespace
      - name: SSH_OPTS
        value: "-i /etc/ssh-key/id_backup -o StrictHostKeyChecking=accept-new"
      - name: BKP_USER
        value: "backup"
      - name: BKP_HOST
        value: "backup.example.com"
      command: ["/bin/bash"]
      args:
      - "-c"
      - "
        set -eo pipefail;
        DIR=${MY_POD_NAMESPACE}/controller/full;
        ARCHIVE=$(date +%Y%m%d-%H%M)_controller-data.tar.gz;
        ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"mkdir -p ${DIR}\";
        tar -C {{ .Values.controller.persistence.pvc.data.mountPath }} -zcf - . | ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"cat > ${DIR}/${ARCHIVE}\";
        ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"cd ${DIR} && ls -tp | grep -v / | tail -n +{{ add1 .Values.controller.backups.full.historyLimit }} | xargs -d '\\n' -r rm --\";
        "
      extraVolumeMounts:
      - name: ssh-key
        mountPath: /etc/ssh-key
      extraVolumes:
      - name: ssh-key
        secret:
          secretName: step-backup-ssh-key
          defaultMode: 0400
      existingClaim: '{{ $.Release.Namespace }}-{{ include "step.controller.component.name" $ }}-data-{{ include "step.controller.component.name" $ }}-0'
      # No pod affinity: the controller is stopped, its volume can be mounted on any node

mongodb:
  backups:
    full:
      suspend: true
      schedule: "00 03 * * 0"
      historyLimit: 3
      image: "registry.example.com/step-backup:1.0.0"
      extraEnvVars:
      - name: MY_POD_NAMESPACE
        valueFrom:
          fieldRef:
            fieldPath: metadata.namespace
      - name: SSH_OPTS
        value: "-i /etc/ssh-key/id_backup -o StrictHostKeyChecking=accept-new"
      - name: BKP_USER
        value: "backup"
      - name: BKP_HOST
        value: "backup.example.com"
      command: ["/bin/bash"]
      args:
      - "-c"
      - "
        set -eo pipefail;
        DIR=${MY_POD_NAMESPACE}/mongodb/full;
        ARCHIVE=$(date +%Y%m%d-%H%M)_mongodb-data.tar.gz;
        ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"mkdir -p ${DIR}\";
        tar -C {{ .Values.mongodb.persistence.mountPath }} -zcf - . | ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"cat > ${DIR}/${ARCHIVE}\";
        ssh ${SSH_OPTS} ${BKP_USER}@${BKP_HOST} \"cd ${DIR} && ls -tp | grep -v / | tail -n +{{ add1 .Values.mongodb.backups.full.historyLimit }} | xargs -d '\\n' -r rm --\";
        "
      extraVolumeMounts:
      - name: ssh-key
        mountPath: /etc/ssh-key
      extraVolumes:
      - name: ssh-key
        secret:
          secretName: step-backup-ssh-key
          defaultMode: 0400
      existingClaim: "datadir-mongodb-0"
      # MongoDB keeps running: the job must run on the node of the MongoDB pod
      affinity:
        podAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app.kubernetes.io/instance
                operator: In
                values:
                - "{{ $.Release.Name }}"
              - key: app.kubernetes.io/component
                operator: In
                values:
                - "mongodb"
            topologyKey: kubernetes.io/hostname

To take a full backup:

  1. Make sure no execution is running, then stop the controller:
    kubectl -n <namespace> scale statefulset <controller> --replicas=0
    kubectl -n <namespace> wait --for=delete pod/<controller>-0 --timeout=300s
    
  2. Wait at least one minute, so that MongoDB writes its pending changes to disk, then start the backup jobs and wait for their completion:
    kubectl -n <namespace> create job --from=cronjob/mongodb-full-backup mongodb-full-backup-manual
    kubectl -n <namespace> create job --from=cronjob/<controller>-full-backup controller-full-backup-manual
    kubectl -n <namespace> wait --for=condition=complete job/mongodb-full-backup-manual job/controller-full-backup-manual --timeout=3600s
    
  3. Start the controller again and delete the jobs:
    kubectl -n <namespace> scale statefulset <controller> --replicas=1
    kubectl -n <namespace> delete job mongodb-full-backup-manual controller-full-backup-manual
    

With PostgreSQL, take the full backup with pg_dump --format=custom without the --exclude-table options, while the controller is stopped.

Running the partial backup jobs manually works the same way, for instance before an upgrade: kubectl -n <namespace> create job --from=cronjob/mongodb-partial-backup mongodb-partial-backup-manual.

Restore procedure

The restore replaces the content of the database and of the controller volume with the content of the backups. Restore both of them from backups taken at the same time. In the commands below, replace <namespace> with the namespace of the Step instance, <controller> with enterprise-controller (Step Enterprise) or controller (Step Community), and the backup host, user and archive names with yours.

1. Stop the controller

kubectl -n <namespace> scale statefulset <controller> --replicas=0
kubectl -n <namespace> wait --for=delete pod/<controller>-0 --timeout=300s

The controller must stay stopped during the whole restore: it must not write to the database or to its volume.

2. Start a restore pod

The restore pod uses the backup image, mounts the SSH key and the volume to restore. Save the following manifest as step-restore.yaml, and set claimName to the PVC to restore:

apiVersion: v1
kind: Pod
metadata:
  name: step-restore
spec:
  restartPolicy: Never
  containers:
  - name: restore
    image: registry.example.com/step-backup:1.0.0
    command: ["sleep", "infinity"]
    env:
    - name: SSH_OPTS
      value: "-i /etc/ssh-key/id_backup -o StrictHostKeyChecking=accept-new"
    volumeMounts:
    - name: ssh-key
      mountPath: /etc/ssh-key
    - name: target
      mountPath: /restore
  volumes:
  - name: ssh-key
    secret:
      secretName: step-backup-ssh-key
      defaultMode: 0400
  - name: target
    persistentVolumeClaim:
      # Controller volume: <namespace>-<controller>-data-<controller>-0
      # MongoDB volume:    datadir-mongodb-0
      claimName: <namespace>-<controller>-data-<controller>-0
kubectl -n <namespace> apply -f step-restore.yaml
kubectl -n <namespace> wait --for=condition=ready pod/step-restore --timeout=300s
kubectl -n <namespace> exec -it step-restore -- bash

List the available archives from the restore pod:

ssh $SSH_OPTS backup@backup.example.com "ls -lt <namespace>/controller/partial <namespace>/mongodb/partial"

3. Restore the controller volume

From the restore pod, with the controller volume mounted under /restore. The archives contain the content of the volume, relative to its root, independently of the configured mount path.

  • From a partial archive, extract the archive over the existing content. The excluded folders (temporary files, attachments) are kept if they still exist:
    ssh $SSH_OPTS backup@backup.example.com "cat <namespace>/controller/partial/20261116-0200_controller-data.tar.gz" \
      | tar -xzf - -C /restore
    
  • From a full archive, empty the volume first:
    find /restore -mindepth 1 -delete
    ssh $SSH_OPTS backup@backup.example.com "cat <namespace>/controller/full/20261115-0300_controller-data.tar.gz" \
      | tar -xzf - -C /restore
    

As the restore pod runs as root, tar restores the original owners of the files.

4. Restore the database

MongoDB from a partial backup

MongoDB keeps running. From the restore pod (the volume it mounts is not used for this step):

ssh $SSH_OPTS backup@backup.example.com "cat <namespace>/mongodb/partial/20261116-0200_step-dump.gz" \
  | mongorestore --host=mongodb --port=27017 --nsInclude='step.*' --drop --gzip --archive

--drop replaces the collections present in the backup. The collections excluded from the backup (executions, reports, measurements, time series…) are kept if the database still contains them, or created empty by the controller at its next startup.

If the MongoDB volume itself is lost or corrupted, recreate it empty before the restore: scale MongoDB down (kubectl -n <namespace> scale statefulset mongodb --replicas=0), delete the PVC datadir-mongodb-0, scale MongoDB up again. The StatefulSet creates a new empty volume.

MongoDB from a full backup

MongoDB must be stopped, and the restore pod must mount the MongoDB volume:

  1. Exit the restore pod and delete it: kubectl -n <namespace> delete pod step-restore.
  2. Stop MongoDB:
    kubectl -n <namespace> scale statefulset mongodb --replicas=0
    kubectl -n <namespace> wait --for=delete pod/mongodb-0 --timeout=300s
    
  3. Set claimName: datadir-mongodb-0 in step-restore.yaml, start the restore pod again and open a shell in it (see step 2).
  4. Empty the volume and extract the archive:
    find /restore -mindepth 1 -delete
    ssh $SSH_OPTS backup@backup.example.com "cat <namespace>/mongodb/full/20261115-0300_mongodb-data.tar.gz" \
      | tar -xzf - -C /restore
    
  5. Exit and delete the restore pod, then start MongoDB:
    kubectl -n <namespace> delete pod step-restore
    kubectl -n <namespace> scale statefulset mongodb --replicas=1
    

PostgreSQL

From the restore pod, with the password of the PostgreSQL Secret (kubectl -n <namespace> get secret postgresql -o jsonpath='{.data.postgres-password}' | base64 -d):

ssh $SSH_OPTS backup@backup.example.com "cat <namespace>/postgresql/partial/20261116-0200_step.dump" > /tmp/step.dump
PGPASSWORD='<password>' pg_restore --host=postgresql --username=postgres --dbname=step --clean --if-exists --no-owner /tmp/step.dump

--clean replaces the tables present in the backup. The tables excluded from a partial backup are kept if the database still contains them, or created empty by the controller at its next startup.

5. Start the controller

Delete the restore pod if it still exists, then start the controller:

kubectl -n <namespace> delete pod step-restore --ignore-not-found
kubectl -n <namespace> scale statefulset <controller> --replicas=1
kubectl -n <namespace> logs -f <controller>-0

Check that:

  • The controller starts without error. If the backup comes from an older Step version, the controller runs its migration tasks at startup, see Migration.
  • The agents are registered again (Admin > Agents).
  • Your plans, keywords, parameters and automation packages are present, and a sample execution succeeds.

The next helm upgrade sets the number of replicas back to the values of the chart.

Summary

Scenario Impact Recovery Data lost
Agent restart Running keywords on this agent fail, handled as defined in the plan Automatic: the agent restarts and registers again None
Database restart Running executions likely fail Automatic: the database restarts, the controller reconnects None
Controller crash Running executions are interrupted and set to ENDED at the next startup Automatic restart; trigger the interrupted plans again if required Results of the steps in progress
Process hanging without exiting Instance not responding Automatic only if probes are enabled, otherwise restart the pod or the service Same as a crash
Database volume full Database stops accepting writes, controller fails Expand the PVC, enable the housekeeping None
Database volume lost or corrupted Instance down Restore the database and the controller volume Changes since the last backup, and the execution history with partial backups
Controller volume full Uploads, deployments and attachments fail Expand the PVC or free the temporary folders None
Controller volume lost or corrupted Resources and automation packages missing Restore the controller volume and the database Changes since the last backup, and the attachments with partial backups
Topics: Maintenance Data Management Browse all topics

Related documentation

  • Agent Runtime Image Naming Convention Migration
  • Agent Runtime Images
  • Agent Provisioning configuration
  • Agent configuration
  • Chart configuration
  • Home
  • Whats new?
  • Release Strategy
  • Set up
  • Administration
    • Maintenance
      • Backup & Restore
      • Housekeeping
      • Disaster Recovery
      • Upgrade / Migration
      • Upgrade / Migration of the Helm chart
      • Agent Runtime Image Naming Convention Migration
      • Troubleshooting
    • Project management
    • Role management
  • SaaS guide
  • User guide
  • Developer guide
  • DevOps
  • AI
  • Plugins
  • Libraries
Step Logo
    • Documentation
    • Tutorials
    • Blogs
    • Product
    • Home
    • Whats new?
    • Release Strategy
    • Set up
    • Administration
      • Maintenance
        • Backup & Restore
        • Housekeeping
        • Disaster Recovery
        • Upgrade / Migration
        • Upgrade / Migration of the Helm chart
        • Agent Runtime Image Naming Convention Migration
        • Troubleshooting
      • Project management
      • Role management
    • SaaS guide
    • User guide
    • Developer guide
    • DevOps
    • AI
    • Plugins
    • Libraries