Whitepaper: Trilio Site Recovery (TSR) — DR for Kubernetes-native VMs

MLflow and Model Registry Backup: Hooks and Point in Time

Chapter 4 of OpenShift AI backup: tutorial and best practices. Lab: OpenShift 4.22, Red Hat OpenShift AI 3.5.1, CloudNativePG 1.30.1, Red Hat MySQL 8.0, Trilio for Kubernetes 5.4.0.

OpenShift AI looks like dashboards and operators. Underneath, the model registry, MLflow and the pipelines server are plain databases. MLflow and model registry backup is the part most teams skip. Lose them and the platform still starts. It just forgets which model was approved, which experiment produced it, and which pipeline run trained it. This chapter of my OpenShift AI backup guide shows the two hooks that make the backup consistent. I restore everything into an isolated copy and compare. I also show the one mistake that turns a harmless test restore into a corrupted production archive.

Which OpenShift AI components are databases

Three components keep their state in relational databases. A fourth often does too:

  • the Model Registry keeps every registered model version in PostgreSQL;

  • MLflow keeps experiments, runs, parameters and metrics in PostgreSQL;

  • AI Pipelines keeps pipeline definitions and run history in MySQL;

  • RAG assistants often keep their vectors in PostgreSQL with pgvector.

Other AI tools do the same. lakeFS keeps its metadata in PostgreSQL, and the lakeFS backup chapter protects it with the same CHECKPOINT hook.

In my lab they all live in one namespace, ai-databases. Here are the pieces and how they talk to each other:

Piece What it does here
CloudNativePG Operator that runs PostgreSQL on OpenShift. The cluster ai-pg holds model_registry, mlflow and rag (pgvector).
Barman Cloud plugin Ships PostgreSQL's WAL (its change diary) to S3 outside the cluster, continuously.
Red Hat MySQL 8 ai-mysql, the external database of the pipelines server. A WAL-G sidecar ships binlogs to the same external S3.
OpenShift service CA Issues and rotates the TLS certificates the registry, MLflow and pipelines use to reach the databases.
Trilio hooks Commands Trilio runs inside the database pods right before the snapshot.

The registry, MLflow and the pipelines server connect over TLS to ai-pg and ai-mysql. The data lives on two persistent volumes, and the change logs stream to S3 outside the cluster. A backup must capture the volumes at a consistent point, plus the clusters, services, certificates and secrets around them.

Snapshot plus WAL: two layers of database backup

Snapshot plus WAL
Snapshot plus WAL

Trilio’s backups are the base points. The WAL and binlog streams fill the gaps between them.

The Trilio backup captures the whole namespace, objects and volumes, consistent thanks to hooks, stored off-site and immutable. That is what you restore after losing the namespace, the cluster or the site.

The WAL and binlog stream gives fine-grained point-in-time recovery between backups. It belongs to the database operator.

They are not alternatives. The backup gives you the base and everything around the database. The WAL gives you the last minutes.

MLflow and model registry backup: the hooks that make it consistent

I tested both commands inside the pods before writing them down. This is the exact YAML running in the lab:

				
					apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata: {name: cnpg-checkpoint-switchwal, namespace: ai-databases}
spec:
  pre:
    execAction:
      command: ["bash", "-c", "psql -U postgres -d postgres -tAc CHECKPOINT"]
    ignoreFailure: false
    maxRetryCount: 2
    timeoutSeconds: 120
  post:
    execAction:
      command: ["bash", "-c", "psql -U postgres -d postgres -tAc 'select pg_switch_wal()'"]
    ignoreFailure: true
    maxRetryCount: 1
    timeoutSeconds: 60
---
apiVersion: triliovault.trilio.io/v1
kind: Hook
metadata: {name: mysql-flush-binlog, namespace: ai-databases}
spec:
  pre:
    execAction:
      command: ["bash", "-c", "MYSQL_PWD=$MYSQL_ROOT_PASSWORD mysql -h 127.0.0.1 -uroot -e 'FLUSH TABLES; FLUSH BINARY LOGS;'"]
    ignoreFailure: false
    maxRetryCount: 2
    timeoutSeconds: 120
  post:
    execAction:
      command: ["true"]
    ignoreFailure: true

				
			

The PostgreSQL pre-hook flushes dirty pages, and the post-hook closes the WAL segment so it ships right away. The MySQL pre-hook flushes tables and starts a new binlog, a clean boundary at the snapshot. Both pre-hooks use ignoreFailure: false: if the database cannot quiesce, there is no backup.

The BackupPlan selects the pods and the container for each hook:

				
					apiVersion: triliovault.trilio.io/v1
kind: BackupPlan
metadata: {name: ai-databases-wasabi, namespace: ai-databases}
spec:
  backupConfig:
    target: {name: wasabi-rhoai-lab-lock, namespace: trilio-system}
    retentionPolicy: {name: rhoai-lab-retain-1, namespace: trilio-system}
    schedulePolicy:
      fullBackupPolicy: {name: rhoai-lab-weekly, namespace: trilio-system}
  hookConfig:
    mode: Sequential
    hooks:
    - hook: {name: cnpg-checkpoint-switchwal, namespace: ai-databases}
      podSelector:
        labels:
        - matchLabels: {"cnpg.io/cluster": "ai-pg"}
      containerRegex: "^postgres$"
    - hook: {name: mysql-flush-binlog, namespace: ai-databases}
      podSelector:
        labels:
        - matchLabels: {"app": "ai-mysql"}
      containerRegex: "^mysql$"

				
			
Hooks in the Trilio UI
Hooks in the Trilio UI

Testing the restore in an isolated copy

First, the backup. A namespace BackupPlan for ai-databases, both hooks, to an immutable Wasabi bucket with Object Lock in governance mode. Full backup: 2.4 GB in 6 min 38 s.

Then the restore as a copy, into a new namespace ai-databases-lab. An egress NetworkPolicy blocks the copy from the original databases and from the external WAL bucket. Without that, the restored database would keep archiving into production’s WAL path, under the same server name.

Restoring “a copy for testing” is the moment people corrupt their own archives. Isolate first, restore second.

What came back

I checked inside the copy and compared with the original:

Check Original Restored copy
Model registry entries iris-classifier, 1:v1.0.0 iris-classifier, 1:v1.0.0
MLflow runs 13 13
pgvector extension 0.8.6 0.8.6
Pipelines in MySQL 1 1
Pipeline runs 2 SUCCEEDED 2 SUCCEEDED
GTID mode ON ON
PostgreSQL primary out of recovery yes yes

Both databases came up on their own, with no manual recovery steps. The hooks had left the files at a clean point.

Point-in-time recovery: back to seconds before the mistake

A nightly backup brings you back to last night. A bad cleanup script runs at 15:21. You want 15:21 minus a few seconds, not last night. That is point-in-time recovery: the Trilio backup is the base, and the WAL and binlog archive replays everything after it.

I tested it on the isolated copy, never on the originals. The copy got its own private archive (a small S3 server in another lab namespace), so it could not touch production’s WAL path. Then I followed this timeline on both databases:

Time (UTC) PostgreSQL (MLflow database) MySQL (pipelines database)
Before the backup marker row T0 marker row T0
Trilio backup, with the hooks 3m51s, to the Object Lock bucket same backup
After the backup marker row T1 at 15:21:30 marker row T1 at 15:21:40
The mistake 15:21:40, all MLflow metrics, params and latest metrics deleted 15:21:50, all pipeline run details and tasks deleted
After the mistake marker row T2 marker row T2

T1 exists only in the archive, not in the backup. T2 and the mistake must not come back. That is the test.

Step 1: Trilio restores only the database volumes

Into a fresh namespace, only the two volumes and the MySQL credentials, from the locked backup:

				
					apiVersion: triliovault.trilio.io/v1
kind: Restore
metadata: {name: pitr-volumes, namespace: ai-databases-pitr-lab}
spec:
  source:
    type: Backup
    backup: {name: pitr-base-1, namespace: ai-databases-lab}
  restoreFlags:
    skipIfAlreadyExists: true
    useOCPNamespaceUIDRange: true
  resourceSelector:
    gvkSelector:
    - groupVersionKind: {group: "", version: v1, kind: PersistentVolumeClaim}
      objects: [ai-pg-1, data-ai-mysql-0]
    - groupVersionKind: {group: "", version: v1, kind: Secret}
      objects: [ai-mysql-cred]

				
			

Completed in 3m29s. At this point both databases are at the backup: T0 is there, T1 is not. The useOCPNamespaceUIDRange flag is explained in the AI agent memory backup chapter.

Step 2: PostgreSQL replays WAL up to a timestamp

I used PostgreSQL’s own archive recovery on the restored data directory. CloudNativePG has its own recovery from volume snapshots and object stores. I wanted a method that works on any volume Trilio restores, whatever the operator.

The pod fetches the archived WAL, drops a recovery.signal file and starts PostgreSQL with these settings:

				
					restore_command = '/tmp/restore.sh %f %p'   # find the segment in the archive copy, gunzip it
recovery_target_time = '2026-11-02 15:21:35.424959+00'
recovery_target_inclusive = off
recovery_target_action = 'promote'

				
			

The log tells the whole story:

				
					restore_command = '/tmp/restore.sh %f %p'   # find the segment in the archive copy, gunzip it
recovery_target_time = '2026-11-02 15:21:35.424959+00'
recovery_target_inclusive = off
recovery_target_action = 'promote'

				
			

Transaction 978 is the delete. PostgreSQL stopped right before it and promoted on a new timeline.

One catch: my first attempt refused to start. Recovery needs max_worker_processes and four other limits at least as high as on the original server. Read them with pg_controldata from the restored directory instead of guessing.

Step 3: MySQL replays binlogs up to a timestamp

MySQL starts on the restored volume with GTIDs on. Then mysqlbinlog replays every archived binlog up to the chosen second:

				
					mysqlbinlog --stop-datetime='2026-11-02 15:21:45' binlog.000420 binlog.000421 binlog.000422 binlog.000423 binlog.000424 \
  | mysql -h127.0.0.1 -uroot

				
			

I passed all the binlogs on purpose, including two from before the backup. With GTIDs the server skips every transaction the snapshot already has: GTID set 1-273 before the replay, 1-274 after. Exactly one transaction applied, the T1 insert.

My first replay failed with GTID_NEXT cannot be set ... when GTID_MODE = OFF. The server that replays needs gtid_mode = ON too. That safety net is worth keeping.

Point-in-time recovery results

Check After the restore only After the replay
PostgreSQL markers T0 T0, T1 (T2 absent)
MLflow metrics / params / latest metrics 9 / 6 / 3 9 / 6 / 3
MySQL markers T0 T0, T1 (T2 absent)
Pipeline run details / tasks 2 / 20 2 / 20

Both databases came back to the moment before the mistake, with the writes made after the backup. The backup’s hooks matter here as well. The MySQL pre-hook rotates the binlog at the snapshot, so the replay starts at a clean file boundary.

What this test does not cover

External databases, a managed cloud database for instance, live outside the cluster. Trilio protects what runs in OpenShift.

Primary and replica databases. This detail comes from the code, not from a lab run. A Trilio hook resolves its pods to the owning workload and runs in every replica. For a primary and replica setup, the script must decide on its own whether it runs on the primary.

Conclusion

The registry, MLflow and pipelines databases are production databases: treat them that way. Back up the namespace, not only the volume, so certificates and secrets come back too. Use hooks; they are the difference between restored and recovered. Keep the WAL and binlog archive, and the backup gets you to any second. Isolate any copy before it starts. Add hooks to your AI database backups.

Thank you for reading! I hope it was useful.

Useful Links

Picture of Rodolfo Casás

Rodolfo Casás

Rodolfo Casás is the Director of Product at Trilio with a special focus on cloud-native computing and virtualization, sovereign clouds, hybrid cloud strategies, telco and data protection.

Table of Contents