Data backup and restoration with Docker Compose

Quick recipes to backup and restore services in the CRISalid Docker Compose stack.

Neo4j

All commands are to be run from docker/neo4j/ in your crisalid-deployment checkout.

πŸ“¦ Full backup

Recommended: stop Neo4j before a backup to ensure a clean snapshot.

Create a compressed archive of the key data directories (preserve numeric ownership for container UID/GID 7474):

sudo tar --numeric-owner -czvf neo4j-full-$(date +%F).tar.gz \
  data import backups plugins

♻️ Restore from a backup archive

Important: Stop Neo4j before restoring files.

  1. Extract the archive to the Neo4j docker directory:
tar -xzvf neo4j-data-20250908.tar.gz \
  -C ~/.../crisalid-deployment/docker/neo4j
  1. Ensure directory ownership matches the container user (UID/GID 7474):
cd ~/code/crisalid-deployment/docker/neo4j
sudo chown -R 7474:7474 data import backups plugins
  1. Start Neo4j again (alone or with other services):
docker compose --profile neo4j up -d neo4j
  1. (Optional) Check logs:
docker compose logs -f neo4j

SoVisuplus Postgresql (container: svp-db, host port 5432)

Make a SQL dump

With a running Docker Compose stack (svp-db container):

# optional: export env if not already loaded
export SVP_DB_NAME=${SVP_DB_NAME}
export SVP_DB_USER=${SVP_DB_USER}

docker compose exec -T svp-db \
  pg_dump -U "$SVP_DB_USER" -d "$SVP_DB_NAME" \
    --format=plain \
    --no-owner --no-privileges \
    --clean --if-exists \
  > "sovisuplus-$(date +%F).sql"

Restore into Docker (same svp-db)

cat sovisuplus-YYYY-MM-DD.sql | \
  docker compose exec -T svp-db psql -U "$SVP_DB_USER" -d "$SVP_DB_NAME"

Restore into local Postgres (on your machine)

PGPASSWORD="$SVP_DB_PASSWORD" psql \
  -h localhost -p 5432 -U "$SVP_DB_USER" -d "$SVP_DB_NAME" \
  -f sovisuplus-YYYY-MM-DD.sql

SVP Harvester Postgresql (container: harvester-db, host port 5433)

With a running Docker Compose stack (harvester-db container):

Make a SQL dump

export HARVESTER_DB_NAME=${HARVESTER_DB_NAME}
export HARVESTER_DB_USER=${HARVESTER_DB_USER}

docker compose exec -T harvester-db \
  pg_dump -U "$HARVESTER_DB_USER" -d "$HARVESTER_DB_NAME" \
    --format=plain \
    --no-owner --no-privileges \
    --clean --if-exists \
  > "harvester-$(date +%F).sql"

Restore into Docker (harvester-db)

cat harvester-YYYY-MM-DD.sql | \
  docker compose exec -T harvester-db psql -U "$HARVESTER_DB_USER" -d "$HARVESTER_DB_NAME"

Restore into local Postgres

Create target DB/user on your host if needed, then:

PGPASSWORD="$HARVESTER_DB_PASSWORD" psql \
  -h localhost -p 5432 -U "$HARVESTER_DB_USER" -d "$HARVESTER_DB_NAME" \
  -f harvester-YYYY-MM-DD.sql