Back to tutorials
Tutorial

Run Open WebUI With Persistent Storage on a VPS

Fix lost chats with Open WebUI persistent storage on a VPS using Docker volumes, backups, and systemd-managed Compose.

By Anurag Singh
Updated on Dec 01, 2026
Category: Tutorial
Share article
Run Open WebUI With Persistent Storage on a VPS

Open WebUI can feel “stateless” the first time you restart the container and your chat history disappears. That usually means the database lived in the container layer instead of durable storage.

This walkthrough sets up Open WebUI persistent storage on a VPS with Docker named volumes. It also adds a simple backup routine and runs the stack under systemd so it comes back cleanly after reboots.

This is meant for real servers (VPS or dedicated). Persistence and backups matter once you’re responsible for uptime, and you can’t shrug off a reboot.

If you don’t already have a server, a HostMyCode VPS is a straightforward place to run Open WebUI. You get enough disk and RAM for daily use.

What you’ll build (and what it fixes)

  • Docker Compose stack for Open WebUI (and optionally Ollama as the local model runtime).
  • Persistent storage using a Docker named volume, so chats and settings survive container updates and host reboots.
  • Systemd-managed Compose so your service restarts reliably after a kernel update or power cycle.
  • Backups of the persistent volume to a folder you can copy off-server.

Prerequisites (VPS sizing, OS, DNS)

Keep sizing simple: the UI is light. The model runtime is what burns CPU, RAM, and disk.

  • OS: Ubuntu Server LTS (a recent LTS is ideal). Commands below assume Ubuntu.
  • CPU/RAM: 2 vCPU / 4 GB RAM works for UI + light use; 4 vCPU / 8–16 GB is more comfortable if you also run Ollama on the same box.
  • Disk: 30–60 GB if you store a few models locally. Named volumes live on your VPS disk.
  • Network: A domain or subdomain like webui.example.com for TLS (recommended).

If you plan to expose Open WebUI to the internet, lock down the box first. Use SSH keys and disable password login at a minimum.

HostMyCode has a step-by-step guide: set up SSH keys and disable password login.

Step 1: Install Docker and Docker Compose plugin

On Ubuntu, install Docker from the official repository (best choice for servers). Run as root or with sudo.

apt-get update
apt-get install -y ca-certificates curl gnupg
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" | \
  tee /etc/apt/sources.list.d/docker.list > /dev/null

apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Confirm:

docker --version
docker compose version

Tip: If you want to run Docker without sudo, add your user to the docker group. Then re-login:

usermod -aG docker $USER

Step 2: Create a Compose project with Open WebUI persistent storage

Use a stable directory so your service files don’t end up scattered. /opt is a solid default.

mkdir -p /opt/open-webui
cd /opt/open-webui

Create docker-compose.yml.

This version uses a named volume (openwebui_data) mounted to /app/backend/data. That path is where Open WebUI stores its database and uploads in common container builds.

nano /opt/open-webui/docker-compose.yml
services:
  open-webui:
    image: ghcr.io/open-webui/open-webui:latest
    container_name: open-webui
    restart: unless-stopped
    ports:
      - "3000:8080"
    environment:
      # If you run Ollama elsewhere, point to it here.
      # For a local Ollama container in this same file, use: http://ollama:11434
      - OLLAMA_BASE_URL=http://ollama:11434
    volumes:
      - openwebui_data:/app/backend/data

  ollama:
    image: ollama/ollama:latest
    container_name: ollama
    restart: unless-stopped
    volumes:
      - ollama_data:/root/.ollama

volumes:
  openwebui_data:
  ollama_data:

Bring it up:

docker compose up -d

Check status and logs:

docker compose ps
docker logs --tail=100 open-webui

Open WebUI should now be reachable at http://YOUR_SERVER_IP:3000. Log in and create a test chat.

Then restart containers to confirm the data survives:

docker compose restart
docker logs --tail=50 open-webui

If your chat history survives the restart, your Open WebUI persistent storage setup is doing its job.

Step 3: Verify the volume is actually used (quick diagnostic)

Trust, but verify. Confirm Docker created the volume and that it’s attached.

docker volume ls | grep openwebui

docker volume inspect openwebui_data

Then confirm the app is writing where you think it is:

docker exec -it open-webui sh -lc "ls -lah /app/backend/data"

You should see files with timestamps from after you logged in and chatted.

If /app/backend/data stays empty, you mounted the wrong path for your image build. Fix the mount path before you do anything else.

Step 4: Put Open WebUI behind HTTPS (recommended for real use)

Binding the UI to a raw port is fine for a private lab. For anything you operate day-to-day, put it behind HTTPS.

If you want a clean, proven setup, follow HostMyCode’s guide: Run Open WebUI on a VPS with Caddy and HTTPS. It handles certificates and renewal automatically.

If you prefer Nginx, the approach is the same. Terminate TLS at the proxy, then forward to 127.0.0.1:3000 (or the Docker bridge).

Your persistence stays in the named volume either way.

Step 5: Run the Compose stack via systemd (reliable reboots and cleaner ops)

Docker restart policies help, but systemd makes the service lifecycle predictable. You can restart everything with one command.

It also ensures the stack always runs from the right directory.

Create a unit file:

nano /etc/systemd/system/open-webui-compose.service
[Unit]
Description=Open WebUI (Docker Compose)
Requires=docker.service
After=docker.service network-online.target
Wants=network-online.target

[Service]
Type=oneshot
WorkingDirectory=/opt/open-webui
RemainAfterExit=yes
TimeoutStartSec=0
ExecStart=/usr/bin/docker compose up -d
ExecStop=/usr/bin/docker compose down

[Install]
WantedBy=multi-user.target

Enable and start:

systemctl daemon-reload
systemctl enable --now open-webui-compose.service
systemctl status open-webui-compose.service

Common pitfall: If you installed the standalone docker-compose binary instead of the Docker Compose plugin, the command changes. This tutorial assumes docker compose works on this host.

Step 6: Back up the Open WebUI volume (simple, predictable, restorable)

Named volumes survive container churn, but they still live on one disk. Backups save you after a bad update, accidental deletion, or a full-disk event.

Create a backup directory:

mkdir -p /var/backups/open-webui
chmod 700 /var/backups/open-webui

Now create a backup script that archives the volume contents. It uses a temporary container to read the volume and write a tarball to the host.

nano /usr/local/sbin/backup-open-webui.sh
#!/usr/bin/env bash
set -euo pipefail

TS=$(date +"%Y%m%d-%H%M%S")
DEST_DIR="/var/backups/open-webui"
OUT="$DEST_DIR/openwebui_data-$TS.tar.gz"

# Optional: stop the app briefly for a cleaner snapshot.
# If you can't tolerate downtime, skip this and accept a tiny risk of an inconsistent archive.
systemctl stop open-webui-compose.service

# Archive the volume
/usr/bin/docker run --rm \
  -v openwebui_data:/data:ro \
  -v "$DEST_DIR":/backup \
  alpine:latest sh -lc "cd /data && tar -czf /backup/$(basename "$OUT") ."

systemctl start open-webui-compose.service

# Keep last 14 backups
find "$DEST_DIR" -type f -name 'openwebui_data-*.tar.gz' -mtime +14 -delete

echo "Wrote: $OUT"

Make it executable and run it once:

chmod 750 /usr/local/sbin/backup-open-webui.sh
/usr/local/sbin/backup-open-webui.sh
ls -lah /var/backups/open-webui

Honest limitation: Stopping the service for backups creates brief downtime. For internal tools, that’s usually acceptable.

If this is public-facing, schedule backups during low traffic. Or run “hot” backups and be strict about restore testing.

Schedule nightly backups with cron:

crontab -e
15 3 * * * /usr/local/sbin/backup-open-webui.sh >> /var/log/backup-open-webui.log 2>&1

Step 7: Test a restore (don’t skip this)

A backup you’ve never restored is just storage you’re paying for. Do a basic restore test on the same server or, better, a second VPS.

Pick a backup file and restore it into a fresh volume. This creates a new volume and extracts the archive into it.

# Stop current stack first
systemctl stop open-webui-compose.service

# Create a new volume
docker volume create openwebui_data_restore_test

# Restore into the new volume
BACKUP_FILE=$(ls -1 /var/backups/open-webui/openwebui_data-*.tar.gz | tail -n 1)

docker run --rm \
  -v openwebui_data_restore_test:/data \
  -v /var/backups/open-webui:/backup \
  alpine:latest sh -lc "cd /data && tar -xzf /backup/$(basename \"$BACKUP_FILE\")"

To actually use the restored volume, you’d edit docker-compose.yml and point open-webui at openwebui_data_restore_test (or swap names).

For a quick confidence check, inspect the restored volume and make sure the files look right:

docker run --rm -v openwebui_data_restore_test:/data alpine:latest sh -lc "ls -lah /data | head"

Then start the stack back up:

systemctl start open-webui-compose.service

Step 8: Tighten access (basic hardening for a self-hosted AI UI)

Open WebUI is effectively a control panel for your models and prompts. Treat it like an admin app, not a toy.

  • Don’t expose port 3000 publicly if you can avoid it. Put it behind a reverse proxy and restrict by IP or SSO.
  • Firewall: allow only 22/tcp (SSH) and 80/443 (web). If you’re new to this, keep it simple with UFW.
  • Fail2ban / CrowdSec: if the server is public, add automated blocking. HostMyCode has a practical guide: Install CrowdSec on Ubuntu VPS.

If you want Open WebUI reachable only to your team, a private overlay network works well. See: Open WebUI with Tailscale on a VPS.

Operational notes: updates, disk growth, and “why did my chats disappear?”

Most “lost chats” cases come down to one of these:

  1. No volume mount (data stored in container layer). Fixed by the Compose volume you added.
  2. Wrong mount path. The container runs, but writes data somewhere else, so the volume stays empty.
  3. Volume removed during cleanup (for example, running docker compose down -v). Avoid -v unless you intend to wipe data.
  4. Disk full, causing database writes to fail. If your VPS runs multiple services, this happens faster than most people expect.

For disk pressure, measure first and clean second. This HostMyCode tutorial lays out a safe workflow: find large files and free space safely.

To update images cleanly:

cd /opt/open-webui
docker compose pull
systemctl restart open-webui-compose.service

docker image prune -f

Reminder: Your chat history lives in the volume. Updating the container image shouldn’t touch it.

Where this fits on real hosting (VPS vs dedicated)

If you’re using Open WebUI as a chat UI for an internal team, a VPS is usually enough. If you’re serving more users and running larger models locally (or you need a GPU), you’ll hit limits quickly.

Most setups hit RAM first, then disk I/O.

HostMyCode can cover both ends: start on a HostMyCode VPS, then move to dedicated servers when you need consistent performance for bigger model runtimes and heavier traffic.

If you want Open WebUI to run like an actual service—durable storage, predictable restarts, and backups you can restore—put it on infrastructure you control. A HostMyCode VPS is a solid baseline, and managed VPS hosting makes sense if you don’t want to spend weekends on OS updates and routine maintenance.

FAQ

Will Open WebUI persistent storage survive container rebuilds and reboots?

Yes—if your data is on a named volume (or bind mount) and you don’t delete that volume. Reboots and docker compose pull + restart won’t remove it.

What command accidentally deletes my chat history?

docker compose down -v is the classic mistake. The -v flag removes named volumes attached to the project.

Should I use a bind mount instead of a named volume?

Named volumes are simpler and less error-prone for most admins. Use a bind mount if you have a specific reason (custom filesystem layout, snapshots, or external backup tooling that expects paths).

Can I back up without stopping the service?

You can, but it’s a “hot” backup. It usually works, but you should test restores and accept a small risk of an inconsistent archive during active writes.

How do I add RAG or document search later?

Start by keeping storage and ops stable (this tutorial). Then add retrieval. A practical next step is Open WebUI RAG with pgvector if you want PostgreSQL-based embeddings storage.

Summary

You now have Open WebUI running with persistent data, systemd-managed restarts, and volume backups you can actually restore. That’s the line between a demo container and a service you can operate.

If you’re setting this up for a team or client work, run it on a properly sized HostMyCode VPS so you control disk, memory, and backup behavior.