Backups and upgrades

Back up and restore the database and artifacts, and upgrade safely.

This page is for the person who runs mlflow on their own server. It explains what to back up, how to back up and restore it, and how to upgrade to a new version with a way back.

The commands use mlflowctl, the management tool that the installer places in your installation directory (and links in /usr/local/bin when you install as root). If you have not installed mlflow yet, see Install. For Kubernetes, see the sections that say so, and Install on Kubernetes.

What to back up

mlflow keeps its state in three places. A useful backup contains all of them.

WhatWhereWhy it matters
The database (PostgreSQL)The postgres serviceUsers, workspaces, projects, pipelines, runs, registered models, deployments, audit log
The artifactsThe /data/artifacts volume, or your object store (S3)Trained models, datasets, plots, batch results
Your secretsThe .env file in the installation directoryIncludes the encryption key that protects stored secrets such as database passwords, AI provider keys and webhook secrets

The database and the artifacts depend on each other: the database says which artifacts exist. Back up both at the same point in time. Restoring one without the other leaves records that point at missing files.

Keep the encryption key

Without the encryption key from .env, a restored installation cannot decrypt the stored secrets. Copy .env to a safe place separately, or add --include-env to the backup (see below).

Back up

Run this on the server:

bash
sudo mlflowctl backup

The command dumps the database, archives the artifacts and writes one file, mlflow-backup-<date>-<time>.tar, to the backups folder in the installation directory. It contains db.dump, artifacts.tgz and a small backup.info with the version and the time. The file is readable by its owner only.

OptionMeaning
--keep NKeep the newest N backups and delete older ones. The default is 7.
--out DIRWrite to another folder, for example a mounted network drive
--include-envAdd the .env file to the backup. The file then contains your secrets, so store it as carefully as .env itself.

Without --include-env, mlflowctl reminds you that .env is not in the file.

Schedule it

Run a backup every night and copy the file away from the server. For example, with cron:

bash
echo '30 3 * * * root /opt/mlflow/mlflowctl backup' | sudo tee /etc/cron.d/mlflow-backup

Use your own installation directory in place of /opt/mlflow. A backup that is stored only on the same disk does not protect you from losing the server, so copy the files to another machine or to cloud storage. Test a restore on a spare server from time to time; a backup you have never restored is a hope, not a backup.

Back up from the app

A platform administrator can also download a backup in the app: open the user menu, select Platform admin, and on the Users tab use Download backup (.tar.gz) in the Backup & restore card. It contains the whole database as JSON plus every artifact. It does not include sessions, so everybody has to sign in again after a restore. This is convenient for small installations and for moving data between servers. For regular backups of a production server, prefer mlflowctl backup: the app builds the whole archive in memory, which is slow for large installations.

Kubernetes and your own database

If you run PostgreSQL yourself or on Kubernetes, use pg_dump and your object store's own tools:

The names assume the release name and fullnameOverride used on the Kubernetes page.

bash
kubectl -n mlflow exec sts/mlflow-postgres -- pg_dump -U <user> <database> | gzip > mlflow-db.sql.gz
aws s3 sync s3://<your-artifact-bucket> ./backup/artifacts

Take the database dump first and the artifact copy second. A database row that points at an artifact which has not been copied yet is fixed by the next copy. The reverse order would give you a database that refers to artifacts you did not capture. Keep, for example, the last 14 daily and 6 monthly backups.

Restore

A restore replaces your current data

Restoring replaces the current database and artifacts with the contents of the backup file. Anything that happened after the backup is lost.

Choose the backup file

Copy the file to the server. The backup must come from a compatible version; see Roll back an upgrade.

Run the restore

bash
sudo mlflowctl restore /opt/mlflow/backups/mlflow-backup-20261122-033000.tar

mlflowctl shows the date of the backup and asks you to confirm (add --yes for scripts). It then takes a safety backup of the current state, stops the web, API and worker services, restores the database and the artifacts, starts everything again and waits until the application is ready.

Check the result

Run sudo mlflowctl status. It shows the version and whether the application is ready. Sign in and open a project to check that your data is there.

If the server is new, install the same version first, copy your .env file back, then restore. In the app, Restore from file… in the same Backup & restore card restores a file that was downloaded from the app, after a confirmation. It refuses to overwrite a populated installation unless you confirm.

Upgrade

Read the release notes

Check the changelog for changes that need attention before you upgrade.

Run the upgrade

bash
sudo mlflowctl upgrade --version <version>

Replace <version> with the version you were given. For a server without internet access, use an offline bundle that you received: sudo mlflowctl upgrade --from-bundle mlflow-bundle.tar. If your images come from a different registry, add --registry <address>.

The command does these steps, in this order, and stops if one fails:

  1. Takes a backup, as mlflowctl backup does.
  2. Writes the new version in .env and remembers the previous version as MLFLOW_PREVIOUS_VERSION.
  3. Pulls the new images.
  4. Starts the database and runs the database migrations.
  5. Restarts the services and waits up to 5 minutes until the application is ready.

If pulling the images or the migration fails, the previous version stays configured. Then check the message: a failed pull may mean you need to sign in to the registry with docker login.

Check the result

bash
sudo mlflowctl status

It shows the new version, the health of each service and whether the application is ready. Use mlflowctl logs api to read the log of the API.

Runs that are in progress when the services restart are interrupted. Upgrade when no important training is running; the Platform administration page shows the queues.

Upgrade on Kubernetes

  1. Take a backup of the database and the artifacts.

  2. Change the image tag, for example helm upgrade mlflow <chart> --reuse-values --set global.imageTag=<new version>.

  3. Apply the database migrations. The chart does not run them for you:

    bash
    kubectl -n mlflow exec deploy/mlflow-api -- pycaret-server migrate

    Migrations that only add things can run while the old version still serves. For a change that is marked as breaking, stop the API first.

  4. Roll the workers after the API, so that jobs in progress can finish first.

  5. Run kubectl -n mlflow exec deploy/mlflow-api -- pycaret-server doctor. It checks the database, Redis and the artifact storage.

Roll back an upgrade

If the new version does not become ready, or you find a problem after the upgrade, go back to the state before it:

bash
sudo mlflowctl restore /opt/mlflow/backups/<the backup made by the upgrade>
sudo mlflowctl upgrade --version <previous version>

The restore returns the database to the shape it had before the migrations. Then the upgrade command puts the previous version back. The newest file in the backups folder is the one that the failed upgrade made, and MLFLOW_PREVIOUS_VERSION in .env names the version to return to. Data entered after the upgrade is lost by a restore. If that matters, ask your mlflow contact for help before you restore.

On Kubernetes, put the previous image tag back and undo the migrations with pycaret-server migrate --revision <previous revision>. Every migration can be reversed. If you are unsure, restore the database and artifacts from the backup you took before the upgrade.

Learn the theory

Lessons on learning.mlflow.es that explain the ideas behind this page.

Updated 2026-11-22