Skip to main content

Move to a new server

Your Qubix license is not tied to the server's hardware. One license runs one copy of Qubix at a time: our licensing server counts the copy that is running. The license travels with your data — when you move the data to a new server and start Qubix there, it keeps working without a new activation code. A new motherboard, another processor or a cloud server that changes its hardware on restart changes nothing.

Keep the old copy stopped: while it runs, the new one waits and shows that another copy is running on the license; it starts by itself a few minutes after the old one stops.

The flow​

Steps​

  1. On the old server — stop the stack so the databases are in a consistent state. Some Qubix services run as separate Docker stacks that docker compose down does not touch, so stop the remaining containers too (this stops every container on the server — Qubix normally has the server to itself):
    Bash
    cd /opt/qubix && docker compose down
    docker ps -q | xargs -r docker stop
  2. Copy the instance directory to the new server. Your instance lives in two places: the /opt/qubix directory and Docker volumes (the next step). The directory holds:
    • the database folder under /opt/qubix/data — your database (all stats, campaigns, events and settings);
    • /opt/qubix/data/letsencrypt — your TLS certificates;
    • the vector-store folder under /opt/qubix/data — the search-by-meaning data;
    • /opt/qubix/data/qubix — the backend's local state;
    • /opt/qubix/.env — your settings and secrets;
    • /opt/qubix/docker-compose.yml — the stack definition.
    Bash
    ssh newserver 'mkdir -p /opt/qubix'
    rsync -a /opt/qubix/ newserver:/opt/qubix/
    Because you stopped the stack in step 1, the database is shut down cleanly and its files are consistent — a plain copy is enough, no separate database dump is needed. The web-server configuration is rebuilt automatically on first start.
  3. Copy the Docker volumes to the new server. Some of the data is kept in Docker volumes, not in /opt/qubix, and a copy of the directory alone loses it. Run this on the old server: it streams every volume straight to the new one, so the old disk needs no free space. The new server holds the archives and the restored volumes at the same time, so it needs about twice the volumes' size free: see the sizes with docker system df -v on the old server and the free space with df -h / on the new one.
    Bash
    set -o pipefail
    ssh newserver 'mkdir -p /root/qubix-volumes'
    for v in $(docker volume ls -q); do
    docker volume inspect -f '{{range $k, $l := .Labels}}{{if ne $k "com.docker.compose.config-hash"}}--label {{$k}}={{$l}} {{end}}{{end}}' "$v" |
    ssh newserver "cat > /root/qubix-volumes/$v.labels" &&
    docker run --rm -v "$v":/volume:ro alpine tar --numeric-owner -C /volume -czf - . |
    ssh newserver "cat > /root/qubix-volumes/$v.tar.gz" ||
    echo "NOT COPIED: $v"
    done
    A line ending with socket ignored is expected: sockets are recreated on start. If the loop prints NOT COPIED, fix the cause and run it again.
  4. Restore the volumes on the new server (Docker must already be installed there), before the first start:
    Bash
    cd /root/qubix-volumes
    for f in *.tar.gz; do
    v=${f%.tar.gz}
    docker volume create $(cat "$v.labels") "$v" >/dev/null
    if [ -n "$(docker run --rm -v "$v":/volume alpine ls -A /volume)" ]; then
    echo "SKIPPED (not empty): $v"
    elif ! docker run --rm -v "$v":/volume -v /root/qubix-volumes:/backup:ro alpine \
    tar --numeric-owner -C /volume -xzpf "/backup/$f"; then
    echo "FAILED: $v"
    fi
    done
    The loop never writes into a volume that already holds data: mixing two sets of database files would corrupt the database.
    • SKIPPED (not empty) — the volume already existed on the new server. Find out what created it before going on.
    • FAILED — the volume is written only partly (usually the disk ran out of space). Remove it with docker volume rm <volume>, fix the cause and run the loop again: volumes restored before are skipped.
  5. Start the stack:
    Bash
    cd /opt/qubix && docker compose pull && docker compose up -d
    Qubix starts with the license it brought along with the data, without a new code. The remaining services come up by themselves a few minutes later, on the restored volumes.
  6. Delete the volume archives once you have made sure the statistics and the rest of the data are in place on the new server — they are an unprotected copy of your data:
    Bash
    rm -rf /root/qubix-volumes
The new server says another copy of Qubix is running on the license?

The strip at the top of the new copy's panel then reads Another copy of Qubix is running on this license. — see The strip at the top of the panel. The old copy is still running. Stop it on the old server — the new one starts by itself a few minutes later:

Bash
cd /opt/qubix && docker compose stop qubixd
Keep off-host backups

Before a move, always keep a backup of /opt/qubix/data and of the Docker volumes off this server — they are your analytics database and the rest of the Qubix data.

What's next​