Back up
This procedure produces a consistent backup set: the databases and the files date from the same moment. SmartAGT creates no backup automatically. The commands target a single server.
What to back up
| Item | Linux | Windows |
|---|---|---|
smartagt, smartagt_vector and smartagt_bff databases |
PostgreSQL | PostgreSQL |
Built-in storage, with the storage-owner.json marker |
/var/lib/smartagt/backend/mediastore/seaweedfs |
C:\app\data\backend\mediastore\seaweedfs |
| Service data | /var/lib/smartagt/backend, /var/lib/smartagt/bff |
C:\app\data\backend, C:\app\data\bff |
| Configuration and installed certificates | /app/config/backend, /app/config/bff |
C:\app\config\backend, C:\app\config\bff |
| Service environment: KEKs, passwords, node identity | /etc/smartagt/*.env |
Service registry |
| Service definitions and their overrides | /etc/systemd/system/ (SmartAGT units) |
Created by the installation |
With S3 storage, the mediastore/seaweedfs directory does not exist: back up the bucket with your tools, during the same interruption. A vector database declared on a separate server is also backed up.
The Backend and Frontend KEKs also stay in your vault: without them, neither the databases nor the files can be read.
Procedure
1. Stop the services
sudo systemctl stop smartagt-frontend-service SmartAGT-AI-Gateway-Service smartagt-scheduler-worker smartagt-rag-embed-worker smartagt-rag-ingestor-worker SmartAGT-Platform-Service
Expected result: systemctl is-active returns inactive for each service, and pgrep -u svc-smartagt-backend returns nothing, built-in storage included.
$services = 'smartagt-frontend-service', 'SmartAGT-AI-Gateway-Service', 'smartagt-scheduler-worker', 'smartagt-rag-embed-worker', 'smartagt-rag-ingestor-worker', 'SmartAGT-Platform-Service'
$services | Where-Object { Get-Service $_ -ErrorAction SilentlyContinue } | Stop-Service
Expected result: Get-Service $services shows Stopped for each installed service.
PostgreSQL keeps running. Stopping Platform also stops the built-in storage.
2. Export the databases
umask 077
backup=/var/backups/smartagt/$(date +%Y%m%d-%H%M%S)
sudo mkdir -p "$backup"
sudo chown "$USER" "$backup"
pg_dump -h <PostgreSQL host> -U smartagt -W -Fc -d smartagt -f "$backup/smartagt.dump"
pg_dump -h <PostgreSQL host> -U smartagt -W -Fc -d smartagt_vector -f "$backup/smartagt_vector.dump"
pg_dump -h <PostgreSQL host> -U smartagt_bff -W -Fc -d smartagt_bff -f "$backup/smartagt_bff.dump"
$backup = "C:\Backup\smartagt\$(Get-Date -Format 'yyyyMMdd-HHmmss')"
New-Item -ItemType Directory -Path $backup | Out-Null
icacls $backup /inheritance:r /grant:r '*S-1-5-32-544:(OI)(CI)F' '*S-1-5-18:(OI)(CI)F' | Out-Null
$pg = 'C:\app\PostgreSQL\18\bin'
& "$pg\pg_dump.exe" -h <PostgreSQL host> -U smartagt -W -Fc -d smartagt -f "$backup\smartagt.dump"
& "$pg\pg_dump.exe" -h <PostgreSQL host> -U smartagt -W -Fc -d smartagt_vector -f "$backup\smartagt_vector.dump"
& "$pg\pg_dump.exe" -h <PostgreSQL host> -U smartagt_bff -W -Fc -d smartagt_bff -f "$backup\smartagt_bff.dump"
Use the PostgreSQL 18 client tools. The -Fc format is meant for pg_restore and is not encrypted.
Expected result: three non-empty .dump files in the set directory.
3. Copy the files
cd /
sudo tar -czpf "$backup/files.tar.gz" \
var/lib/smartagt app/config etc/smartagt \
etc/systemd/system/SmartAGT-* etc/systemd/system/smartagt-*
Expected result: tar -tzf "$backup/files.tar.gz" lists var/lib/smartagt/backend/mediastore/seaweedfs/storage-owner.json.
robocopy C:\app\data "$backup\data" /E /COPY:DAT /R:1 /W:1 | Out-Null
robocopy C:\app\config "$backup\config" /E /COPY:DAT /R:1 /W:1 | Out-Null
foreach ($name in $services | Where-Object { Get-Service $_ -ErrorAction SilentlyContinue }) {
reg export "HKLM\SYSTEM\CurrentControlSet\Services\$name" "$backup\$name.reg" /y | Out-Null
}
Expected result: $backup\data\backend\mediastore\seaweedfs\storage-owner.json exists, with one .reg file per service.
The model cache, backend/models under the data directory, can be excluded: it downloads again if the server reaches Hugging Face. A manually placed model must be placed again.
4. Restart the services
sudo systemctl start SmartAGT-Platform-Service smartagt-rag-ingestor-worker smartagt-rag-embed-worker smartagt-scheduler-worker SmartAGT-AI-Gateway-Service smartagt-frontend-service
[array]::Reverse($services)
$services | Where-Object { Get-Service $_ -ErrorAction SilentlyContinue } | Start-Service
Only start the installed services. AI Gateway is optional.
Expected result: the login page opens.
5. Protect the set
The set contains the service environment, hence the KEKs and the passwords. Encrypt it, keep it off the server and limit its access to your backup administrators. Keep the version of the installed packages with it: a restore is done on the same version.
Special cases
Consistency between databases and files
The three exports and the file copy must come from the same interruption. Built-in storage older or newer than the smartagt database may refuse to start at restore time, or leave documents missing.
Cluster
In a cluster, the storage is S3. Stop the services on all nodes, export the databases once, back up the bucket, then copy the configuration and environment of each node.