Skip to content

Operations ​

This page covers the regular work on an instance that you installed with git clone and Docker Compose: updates, backups, restore, data retention, the health check and the logs. Run every command from the sensora folder you cloned.

Update to a new version ​

  1. Make a backup. See Back up. The Changelog lists what changed.

  2. Get the new source and rebuild.

    bash
    git pull
    docker compose -f deploy/docker-compose.yml up -d --build
  3. Check the result.

    bash
    docker compose -f deploy/docker-compose.yml ps
    curl http://localhost:8090/health

Database migrations run by themselves. The migrate service applies the new ones at every start, and the server starts only after it finished without an error. If the server does not start, read the reason with:

bash
docker compose -f deploy/docker-compose.yml logs migrate

The dashboard and the API are away for a short time while the containers are replaced. Your data stays. Migrations only go forward. To go back to an older version, check out the older source and restore the backup you made before the update. Readings stored after that backup are lost.

INFO

Settings, then Server & storage shows the command docker compose pull && docker compose up -d. That command needs published images, which do not exist yet. Use the commands on this page. A one-command updater will come with published images.

An instance built from source shows dev as its version. To name the exact version, for example in a bug report, print the commit you built from:

bash
git log -1 --format='%h %ad %s' --date=short

Back up ​

Sensora does not make backups by itself. A complete backup has three parts.

PartHoldsHow
The databaseDevices, readings, rules, dashboards, customers, settingspg_dump, below
The firmware volumeImages you uploaded for remote updatestar, below. Skip it if you do not use remote updates.
deploy/.envENCRYPTION_KEY and your other settingsCopy the file to a safe place

WARNING

A database backup is of little use without the ENCRYPTION_KEY it was made with. Device secrets, API keys and integration secrets in the backup work only with that key.

Back up the database while the stack is running:

bash
docker compose -f deploy/docker-compose.yml exec -T db \
  pg_dump -U postgres -Fc sensora > sensora-$(date +%F).dump

If you changed DB_USER or DB_NAME in deploy/.env, use your values in place of postgres and sensora.

Back up the firmware volume:

bash
docker run --rm \
  -v sensora-oss_sensora-oss-ota:/data:ro \
  -v "$PWD":/backup \
  alpine tar czf /backup/sensora-ota-$(date +%F).tar.gz -C /data .

Run these commands on a schedule, for example from cron, and copy the files to another machine.

Restore ​

A restore replaces the whole database with the content of a dump file.

On a new machine, first install Sensora with the deploy/.env of the old machine and start it once. The first start creates a database role that the restore needs.

  1. Stop the services that use the database.

    bash
    docker compose -f deploy/docker-compose.yml stop app web
  2. Replace the database with an empty one.

    bash
    docker compose -f deploy/docker-compose.yml exec -T db \
      psql -U postgres -d postgres \
      -c "DROP DATABASE IF EXISTS sensora WITH (FORCE)" \
      -c "CREATE DATABASE sensora TEMPLATE template0"
  3. Load the dump. Use the name of your own file.

    bash
    docker compose -f deploy/docker-compose.yml exec -T db \
      pg_restore -U postgres -d sensora --no-owner < sensora-2026-11-19.dump
  4. Start everything again. migrate applies any migration that is newer than the dump.

    bash
    docker compose -f deploy/docker-compose.yml up -d
  5. Check curl http://localhost:8090/health and open the dashboard.

To restore the firmware volume:

bash
docker run --rm \
  -v sensora-oss_sensora-oss-ota:/data \
  -v "$PWD":/backup:ro \
  alpine tar xzf /backup/sensora-ota-2026-11-19.tar.gz -C /data

How long data is kept ​

By default Sensora keeps readings forever. Change this under Settings, then Server & storage, in the Storage section.

The Server and storage settings: version and health, the Storage section with three retention choices, and the services section

Row on screenWhat it isChoices
Raw telemetryEvery reading as it arrived30 days, 90 days, 180 days, 1 year, Forever
Rolled-up · 5-min average5-minute averages, used for charts over long ranges6 months, 1 year, 2 years, Forever
EventsDevice status changes7 days, 30 days, 90 days, Forever

A change is saved at once. A background job deletes older rows shortly after the server starts and then every hour. Deleted data cannot be brought back.

Rule execution logs are kept for 30 days and settled items in an integration's inbox for 7 days. These two have no setting on screen. Configuration lists the RETENTION_ variables for all five.

How much disk readings take ​

Each value in a message is stored as one reading. A message with temperature and humidity stores two readings.

As a rough measure from a test instance with 3.2 million readings: one reading took about 200 bytes with its indexes, and each 5-minute average took about the same again. The whole database was 1.2 GB and its dump file 56 MB. One device that sends 4 values every minute then needs about 1 MB per day for readings.

The Disk row on screen counts readings, 5-minute averages and events only. The total next to it, "of 100 GB", is the value of the STORAGE_CAP_GB variable and not the size of your disk. Check the real free space on the host:

bash
df -h
docker system df -v

Health check ​

bash
curl -i http://localhost:8090/health
AnswerMeaning
200 with {"status":"ok","time":"..."}The server runs and reaches the database. time is the clock of the server.
503 with "status":"unavailable"The server runs and cannot reach the database.
502 or no answerThe app or web service is not running.

The path needs no key and no password, so a monitoring service can call it. See Security for what else is public.

Logs ​

bash
docker compose -f deploy/docker-compose.yml logs -f --tail 100 app

Use web, db, broker or migrate in place of app for the other services. The app log has the server start, the MQTT connection, retention runs and errors. The web log has one line per HTTP request.

With Docker's default settings these logs grow without a size limit. Set up log rotation in Docker on an instance that runs for a long time.

What devices and rules did is in the dashboard, under Logs. See Logs.

Stop, start and restart ​

bash
docker compose -f deploy/docker-compose.yml restart app    # restart the server only
docker compose -f deploy/docker-compose.yml stop           # stop everything, keep data
docker compose -f deploy/docker-compose.yml up -d          # start again

DANGER

docker compose -f deploy/docker-compose.yml down -v deletes the data volumes. Do not use -v unless you want an empty instance.

Sensora is open source under the Apache 2.0 license.