Skip to main content

Updating WEVA

Follow this tutorial to upgrade the WEVA services while preserving device configurations and historical data.

1. Backup Existing Data​

Before performing any update, if using the older version, it is critical to backup the database data to avoid any data loss.

Linux and Mac

  • Create a file update.sh.
  • Copy this into the file πŸ‘‡:
#!/usr/bin/env bash

# Exit immediately if a command exits with a non-zero status
set -e

# --- CONFIGURATION ---
CONTAINER_NAME="mysql-db" # Name of your MySQL container
DB_USER="root" # MySQL User
DB_PASSWORD="mypassword" # MySQL Password
DB_NAME="wagopa" # Database to back up
BACKUP_DIR="./db_dumps" # Local directory to store backups
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
BACKUP_FILE="${BACKUP_DIR}/backup_${DB_NAME}_${TIMESTAMP}.sql"

echo "πŸ”„ Starting clean container update workflow..."

# 1. Ensure backup directory exists
mkdir -p "$BACKUP_DIR"

# 2. Database Backup (Failsafe Mechanism)
echo "πŸ’Ύ Backing up MySQL database..."
if docker exec "$CONTAINER_NAME" mysqldump -u"$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" > "$BACKUP_FILE"; then
echo "βœ… Backup saved successfully to: $BACKUP_FILE"
else
echo "❌ CRITICAL: MySQL backup failed! Aborting update to protect system integrity."
exit 1
fi

# 3. Pull New Images (Staging)
echo "πŸ“₯ Pulling the latest container images..."
docker compose pull

# 4. Clean Tear Down
echo "πŸ›‘ Tearing down the old container stack..."
docker compose down

# 5. Bring up the Updated Stack
echo "πŸš€ Booting up the updated containers..."
docker compose up -d

echo "πŸŽ‰ Clean update completed successfully!"
  • Run this in your terminal to ensure the file is executable:
chmod +x update.sh

Windows

  • Create a file update.ps1.
  • Copy this into the file πŸ‘‡:
# --- CONFIGURATION ---
[cite_start]$ContainerName = "mysql-db" # Name of your MySQL container
[cite_start]$DbUser = "root" # MySQL User
[cite_start]$DbPassword = "mypassword" # MySQL Password
[cite_start]$DbName = "wagopa" # Database to back up
[cite_start]$BackupDir = "./db_dumps" # Local directory to store backups
$Timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$BackupFile = "$BackupDir/backup_${DbName}_${Timestamp}.sql"

Write-Host "πŸ”„ Starting clean container update workflow..." -ForegroundColor Cyan

# 1. Ensure the backup directory exists
if (-not (Test-Path $BackupDir)) {
New-Item -ItemType Directory -Path $BackupDir | Out-Null
}

# 2. Database Backup (Failsafe Mechanism)
Write-Host "πŸ’Ύ Backing up MySQL database..." -ForegroundColor Yellow

# We use --resultvariable to accurately catch errors across the Docker-to-PowerShell CLI stream
docker exec $ContainerName mysqldump -u"$DbUser" -p"$DbPassword" "$DbName" 2>$null | Out-File -FilePath $BackupFile -Encoding utf8

if ($LASTEXITCODE -eq 0) {
Write-Host "βœ… Backup saved successfully to: $BackupFile" -ForegroundColor Green
} else {
Write-Host "❌ CRITICAL: MySQL backup failed! Aborting update to protect system integrity." -ForegroundColor Red
# Clean up the empty or corrupted file if the dump failed
if (Test-Path $BackupFile) { Remove-Item $BackupFile }
exit 1
}

# 3. Pull New Images (Staging)
Write-Host "πŸ“₯ Pulling the latest container images..." -ForegroundColor Yellow
docker compose pull

# 4. Clean Tear Down
Write-Host "πŸ›‘ Tearing down the old container stack..." -ForegroundColor Yellow
docker compose down

# 5. Bring up the Updated Stack
Write-Host "πŸš€ Booting up the updated containers..." -ForegroundColor Green
docker compose up -d

Write-Host "πŸŽ‰ Clean update completed successfully!" -ForegroundColor Green

Run this in your powershell to give execution permission:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

2. Post-Update Checks​

  • Verify the version number in the footer of the WEVA dashboard.
  • Check the logs for any migration errors:
    docker logs weva

Update Success Placeholder Screenshot: Terminal output showing Successful container creation and startup.