Skip to content

Backup and restore

guidemaintain-backup-and-restore

Keep a copy of the Platforma data that you can restore after a failure or a failed upgrade.

A backup of the database keeps all projects of users safe: after a failure or a failed upgrade, you restore it and continue where you stopped. The BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary makes these backups by itself, every day, so you always have earlier copies to go back to. Keep a copy outside the installation too, together with a copy of the secret and the settings that it needs.

What to keep

The database is the most important part: it holds all projects, and a project refers to its results in the primary storageprimary storage — The bucket (Amazon S3 or Google Cloud Storage) or folder where Platforma keeps all results and uploaded files. Glossary. Without the database, the results stay in storage, but no project refers to them.

Data Where it is How to keep it
Database: projects, BlocksBlock — A small application for one step of an analysis, for example the import of reads or clustering. It can combine several tools. Glossary, users, and the references to all results KubernetesKubernetes — A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster. Glossary: a volume in the cluster. Single Server modeSingle Server mode — The mode in which the Backend and all its jobs run on one Linux machine, the server, with no Kubernetes cluster. Glossary: <main-root>/rocksdb The Backend makes a backup every day: see Automatic backups of the database. Before each upgrade, also make a backup now, and copy it out of the installation.
Results: the files that analyses make and that users upload The primary storage: a bucket, or in Single Server mode the folder <main-root>/primary Turn on object versioning or soft delete on the bucket. In Single Server mode, copy the folder.
Master secret: encrypts the credentials that the database keeps Kubernetes: the Secret platforma-master-secret. The installers also keep it in AWS Systems Manager Parameter Store or Google Secret Manager. Single Server mode: the master secret file, or the login token that the Backend makes the secret from Keep a copy outside the installation.
Settings AWS installer: the stack parameters. Google Cloud installer: your answers and the release of platforma-helm. Terraform modulesTerraform modules — The Terraform code that MiLaboratories provides to install Platforma. The cloud-specific Terraform modules make the cluster and its cloud parts in AWS or Google Cloud; the cloud-agnostic Terraform modules install Platforma into the cluster. Glossary: your .tfvars files and the Terraform state. Helm chart: your values file. Single Server mode: the systemd unit and /etc/platforma Keep them in version control.
Workspaceworkspace — The storage where the Backend and all jobs keep the working files of running jobs. The Backend and the jobs use it at the same time. In Kubernetes, it is a network file system; in Single Server mode, it is a folder on the server. Glossary: the working files of jobsjob — One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster. Glossary that run now Kubernetes: a file system that the Backend and all jobs share. Single Server mode: a folder on the server No backup is necessary: jobs make it again.

A database backup is useful only together with the primary storage and the master secret of the same installation.

The files that users import from a data librarydata library — A folder or bucket with input data of the company. Users select files from it in the Desktop App. Platforma only reads it. Glossary stay in the library: a project keeps only a link to them. To keep them with the results, copy them into the primary storage: see Copy the files of a library into the primary storage.

Make a backup now

The Backend makes its automatic backups on a schedule. Right before each upgrade, make one more backup now, so that it holds the last changes of users.

Tool: CloudFormation template

The commands use the namespace platforma and the release platforma. Change them if your installation uses other names.

  1. Write the database to a file on your computer. The BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary gives a copy of its database through its debug interface, which listens only inside the pod. The Backend continues to work during the copy.

    Terminal window
    kubectl exec deployment/platforma -n platforma -c platforma -- \
    sh -c 'curl -fsS http://127.0.0.1:9091/db/state_raw | gzip' > backup-$(date +%F).tsv.gz

    When TLS is on in the chart (network.tls.enabled: true), the debug interface accepts only HTTPS. Then use curl -fsSk https://127.0.0.1:9091/db/state_raw in the command: the certificate names the domain of the installation, not 127.0.0.1, and the connection does not go out of the pod.

    The time depends on the size of the database: from seconds to hours.

  2. Check the file. The first test finds a file that stopped too early, for example when the connection to the cluster dropped. The second test finds an empty copy, for example when the debug interface refused the request. The third test finds the error message that the Backend writes as the last line when the copy fails.

    Terminal window
    F=backup-$(date +%F).tsv.gz
    gzip -t "$F" && [ -n "$(gzip -dc "$F" | head -c 100)" ] \
    && ! gzip -dc "$F" | tail -1 | grep -q 'Error happened' && echo OK

    Result: OK. Keep the file in a place outside the installation, for example a bucket that Platforma does not use.

  3. Keep a copy of the master secret if you do not have one outside the cluster.

    Terminal window
    kubectl get secret platforma-master-secret -n platforma \
    -o jsonpath='{.data.master-secret}' | base64 -d > master-secret.txt

    Keep the file as you keep a password, then delete the local copy.

Disk snapshots

On Kubernetes, the database is on one cloud disk: the volume platforma-database. A snapshot of this disk is a fast copy that the cloud keeps for you. Each new snapshot keeps only the data that changed, so you can make one every day at a low cost, and a restore takes minutes. A snapshot works only in the same cloud project or account. For a copy that you can restore anywhere, also make the backup of Make a backup now.

A snapshot holds only the database. Protect the primary storage separately: the installers do not turn on object versioning on the bucket, so turn it on, or soft delete on Google Cloud Storage.

Tool: CloudFormation template

The database disk is a gp3 EBS volume (StorageClass gp3-retain, driver ebs.csi.aws.com). The installer does not install the snapshot parts of Kubernetes. Before the first snapshot:

  1. Add the Amazon EKS add-on snapshot-controller to the cluster. It also adds the Kubernetes objects for snapshots.

    Terminal window
    aws eks create-addon --cluster-name <cluster-name> --addon-name snapshot-controller
  2. Create a VolumeSnapshotClass:

    apiVersion: snapshot.storage.k8s.io/v1
    kind: VolumeSnapshotClass
    metadata:
    name: platforma-database
    driver: ebs.csi.aws.com
    deletionPolicy: Retain

To make snapshots on a schedule without Kubernetes, use AWS Backup or Amazon Data Lifecycle Manager on the EBS volume. The cloud makes such a snapshot while the Backend runs. It is crash-consistent: the database is as after a sudden power failure, and the Backend usually starts on it. Use it as a second copy, not as your only backup. The ID of the volume is in its PersistentVolume:

Terminal window
kubectl get pv $(kubectl get pvc platforma-database -n platforma -o jsonpath='{.spec.volumeName}') \
-o jsonpath='{.spec.csi.volumeHandle}{"\n"}'

deletionPolicy: Retain keeps the snapshot in the cloud when somebody deletes its KubernetesKubernetes — A system that runs programs on a group of machines (a cluster). Platforma can run in a Kubernetes cluster. Glossary object, for example with the namespace.

Make a snapshot. Stop the BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary for the snapshot, so that the disk does not change during the copy.

  1. Stop the Backend.

    Terminal window
    kubectl scale deployment platforma -n platforma --replicas=0

    Check that the BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary pod is gone. The filter leaves out the pods of the cleanup jobjob — One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster. Glossary, which have the same release label:

    Terminal window
    kubectl get pods -n platforma -l 'app.kubernetes.io/instance=platforma,!app.kubernetes.io/component'

    Result: No resources found in platforma namespace. If the list shows a pod, also in the state Terminating, wait and run the command again. Do not continue while the pod exists: it can still write to the database.

  2. Make the snapshot, and wait until it is ready:

    Terminal window
    cat <<'EOF' | kubectl apply -f -
    apiVersion: snapshot.storage.k8s.io/v1
    kind: VolumeSnapshot
    metadata:
    name: platforma-database-2026-11-24
    namespace: platforma
    spec:
    volumeSnapshotClassName: platforma-database
    source:
    persistentVolumeClaimName: platforma-database
    EOF
    kubectl wait volumesnapshot/platforma-database-2026-11-24 -n platforma \
    --for=jsonpath='{.status.readyToUse}'=true --timeout=60m

    Use the date in the name of each snapshot. The first snapshot copies the full disk and takes the longest.

  3. Start the Backend.

    Terminal window
    kubectl scale deployment platforma -n platforma --replicas=1

Restore from a snapshot. The restore makes a new database disk from the snapshot.

  1. Stop the Backend.

    Terminal window
    kubectl scale deployment platforma -n platforma --replicas=0

    Check that the BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary pod is gone. The filter leaves out the pods of the cleanup jobjob — One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster. Glossary, which have the same release label:

    Terminal window
    kubectl get pods -n platforma -l 'app.kubernetes.io/instance=platforma,!app.kubernetes.io/component'

    Result: No resources found in platforma namespace. If the list shows a pod, also in the state Terminating, wait and run the command again. Do not continue while the pod exists: it can still write to the database.

  2. Check the snapshot. Do not continue unless the result is true:

    Terminal window
    kubectl get volumesnapshot platforma-database-2026-11-24 -n platforma \
    -o jsonpath='{.status.readyToUse}{"\n"}'
  3. Keep the old disk, and write down its settings. The StorageClasses of the installers have reclaimPolicy: Delete: without this step, the deletion of the volume claim deletes the disk.

    Terminal window
    PV=$(kubectl get pvc platforma-database -n platforma -o jsonpath='{.spec.volumeName}')
    kubectl patch pv "$PV" -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}'
    kubectl get pvc platforma-database -n platforma \
    -o jsonpath='{.spec.storageClassName} {.spec.resources.requests.storage}{"\n"}'

    Result: the StorageClass and the size of the volume, for example gp3 50Gi.

  4. Make a new database volume from the snapshot. Use the StorageClass and the size of step 3. The labels and annotations let Helm keep managing the new volume.

    Terminal window
    kubectl delete pvc platforma-database -n platforma
    cat <<'EOF' | kubectl apply -f -
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    name: platforma-database
    namespace: platforma
    labels:
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: database
    annotations:
    meta.helm.sh/release-name: platforma
    meta.helm.sh/release-namespace: platforma
    helm.sh/resource-policy: keep
    spec:
    accessModes: [ReadWriteOnce]
    storageClassName: <storage-class>
    resources:
    requests:
    storage: <size>
    dataSource:
    apiGroup: snapshot.storage.k8s.io
    kind: VolumeSnapshot
    name: platforma-database-2026-11-24
    EOF
  5. Start the Backend.

    Terminal window
    kubectl scale deployment platforma -n platforma --replicas=1

    Result: the Backend pod is Running and Ready. In the Desktop AppDesktop App — The program that each user installs on their own computer to work with Platforma. It is a client of the Backend. Glossary, an existing project opens with its results. Then delete the old disk: kubectl delete pv "$PV", and delete the disk in the console of the cloud account of your company.

Restore

A restore replaces the database with the backup. All changes that users made after the backup are lost. Results made after the backup stay in the storage, but no project refers to them.

Automatic backups of the database

After an outage, a damaged database or any other failure, you can always go back to an earlier copy of the database: the Backend keeps them in the primary storage.

  • When: the Backend makes a backup when it starts, and then every 24 hours while it runs.
  • Where: in the folder db-backups/ of the primary storage: the bucket and its prefix, or in Single Server mode the folder /data/platforma/primary/db-backups/.
  • Names: the date and time of the backup in UTC, for example 2026-11-27_031500.tsv.gz. The names sort from the oldest to the newest.
  • How many: the newest 14. After each new backup, the Backend deletes the older ones.
  • Checks: before the upload, the Backend compares the backup with the database.

The same holds in Kubernetes and in Single Server mode. To change the interval, the number of kept backups, the folder, or to send the backups to a different bucket or folder, see Backups of the database. The automatic backups are as safe as the primary storage: protect it, as What to keep says, or send the backups to a different place.

Get the backup file

Choose the newest backup from before the failure. The commands use the bucket and the prefix of the primary storage; if the backups go to a different place, use that place.

List the backups, then copy the chosen file to your computer.

AWS S3 bucket
aws s3 ls s3://<bucket>/<prefix>db-backups/
aws s3 cp s3://<bucket>/<prefix>db-backups/<name>.tsv.gz .
GCS bucket
gcloud storage ls gs://<bucket>/<prefix>db-backups/
gcloud storage cp gs://<bucket>/<prefix>db-backups/<name>.tsv.gz .

Result: the file is on your computer. It is the <backup-file> of the restore steps.

Put back the database

Tool: CloudFormation template

  1. Stop the BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary.

    Terminal window
    kubectl scale deployment platforma -n platforma --replicas=0

    Check that the BackendBackend — The server program of Platforma. It keeps the projects, runs the Blocks and starts jobs. Glossary pod is gone. The filter leaves out the pods of the cleanup jobjob — One run of a tool on data. The Backend starts jobs on the server where it runs, or in a Kubernetes cluster. Glossary, which have the same release label:

    Terminal window
    kubectl get pods -n platforma -l 'app.kubernetes.io/instance=platforma,!app.kubernetes.io/component'

    Result: No resources found in platforma namespace. If the list shows a pod, also in the state Terminating, wait and run the command again. Do not continue while the pod exists: it can still write to the database.

  2. Start a restore pod. The pod copies the settings of the Backend: the same nodes, resources and database volume. Set IMAGE to the Backend image that must run after the restore. After a failed upgrade, this is the old image. The command makes the pod with jq: install it on your computer first.

    Terminal window
    IMAGE=<backend-image>
    kubectl get deployment platforma -n platforma -o json | jq --arg image "$IMAGE" '
    .spec.template.spec as $s
    | ($s.containers[] | select(.name == "platforma")) as $c
    | {
    apiVersion: "v1", kind: "Pod",
    metadata: {name: "platforma-restore", namespace: .metadata.namespace},
    spec: {
    restartPolicy: "Never",
    securityContext: $s.securityContext,
    nodeSelector: $s.nodeSelector,
    tolerations: $s.tolerations,
    affinity: $s.affinity,
    containers: [{
    name: "restore",
    image: $image,
    command: ["sleep", "infinity"],
    securityContext: $c.securityContext,
    resources: $c.resources,
    volumeMounts: [{name: "database", mountPath: "/data/database"}]
    }],
    volumes: [$s.volumes[] | select(.name == "database")]
    }
    }' | kubectl apply -f -
    kubectl wait pod/platforma-restore -n platforma --for=condition=Ready --timeout=600s
  3. Restore the backup. Copy the file into the pod, and empty the database folder: a newer version can write files that the restore of an older version cannot open. Then start the restore in the background, so that it continues if your connection stops:

    Terminal window
    kubectl exec -i platforma-restore -n platforma -- \
    sh -c 'cat > /tmp/backup.tsv.gz' < <backup-file>
    kubectl exec platforma-restore -n platforma -- \
    find /data/database -mindepth 1 -maxdepth 1 ! -name lost+found -exec rm -rf {} +
    kubectl exec platforma-restore -n platforma -- sh -c \
    'nohup sh -c "/app/platforma --restore-db=/tmp/backup.tsv.gz --db-dir=/data/database --force && echo RESTORE OK || echo RESTORE FAILED" > /tmp/restore.log 2>&1 &'

    The restore takes from minutes to hours: this depends on the size of the database. To see the progress:

    Terminal window
    kubectl exec platforma-restore -n platforma -- tail -5 /tmp/restore.log

    Result: the last line is RESTORE OK. Then delete the pod: kubectl delete pod platforma-restore -n platforma. If the last line is RESTORE FAILED, keep the pod and send /tmp/restore.log to MiLaboratories support.

  4. Start the Backend. After a failed upgrade, deploy the old version: see Go back to the old version. In all other cases:

    Terminal window
    kubectl scale deployment platforma -n platforma --replicas=1

    Result: the Backend pod is Running and Ready. In the Desktop AppDesktop App — The program that each user installs on their own computer to work with Platforma. It is a client of the Backend. Glossary, an existing project opens with its results.

Next