Restore
This procedure returns an installation to the state of a set produced by Back up. The commands target a single server.
Prerequisites
- Backend and Frontend packages of the same version as the set, installed according to Install the Backend and Install the Frontend: service accounts on Linux, services on Windows.
- PostgreSQL 18 with pgvector, and the
smartagtandsmartagt_bffroles with the passwords recorded in the set: Prepare the databases. - The decrypted backup set, in a directory reserved to administrators. The commands refer to it as
$backup.
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
$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: each installed service is stopped.
2. Recreate the databases
Open psql with the postgres account, as for preparing the databases. These commands delete the existing databases.
DROP DATABASE IF EXISTS smartagt;
DROP DATABASE IF EXISTS smartagt_vector;
DROP DATABASE IF EXISTS smartagt_bff;
CREATE DATABASE smartagt OWNER smartagt ENCODING 'UTF8' TEMPLATE template0;
CREATE DATABASE smartagt_vector OWNER smartagt ENCODING 'UTF8' TEMPLATE template0;
CREATE DATABASE smartagt_bff OWNER smartagt_bff ENCODING 'UTF8' TEMPLATE template0;
REVOKE ALL ON DATABASE smartagt FROM PUBLIC;
REVOKE ALL ON DATABASE smartagt_vector FROM PUBLIC;
REVOKE ALL ON DATABASE smartagt_bff FROM PUBLIC;
Expected result: psql answers DROP DATABASE three times, CREATE DATABASE three times, then REVOKE three times.
3. Restore the databases
sudo cat "$backup/smartagt.dump" | sudo -u postgres pg_restore -d smartagt
sudo cat "$backup/smartagt_vector.dump" | sudo -u postgres pg_restore -d smartagt_vector
sudo cat "$backup/smartagt_bff.dump" | sudo -u postgres pg_restore -d smartagt_bff
$pg = 'C:\app\PostgreSQL\18\bin'
& "$pg\pg_restore.exe" -U postgres -d smartagt "$backup\smartagt.dump"
& "$pg\pg_restore.exe" -U postgres -d smartagt_vector "$backup\smartagt_vector.dump"
& "$pg\pg_restore.exe" -U postgres -d smartagt_bff "$backup\smartagt_bff.dump"
The postgres account recreates the extensions and gives each object back to its original role. If PostgreSQL runs on another server, add -h <PostgreSQL host> and a superuser.
Expected result: each command ends without error.
4. Restore the files
cd /
sudo rm -rf /var/lib/smartagt/backend/mediastore/seaweedfs
sudo tar -xzpf "$backup/files.tar.gz"
sudo systemctl daemon-reload
Expected result: /var/lib/smartagt/backend/mediastore/seaweedfs/storage-owner.json exists and belongs to svc-smartagt-backend.
Remove-Item C:\app\data\backend\mediastore\seaweedfs -Recurse -Force -ErrorAction SilentlyContinue
robocopy "$backup\data" C:\app\data /E /COPY:DAT /R:1 /W:1 | Out-Null
robocopy "$backup\config" C:\app\config /E /COPY:DAT /R:1 /W:1 | Out-Null
Get-ChildItem "$backup\*.reg" | ForEach-Object { reg import $_.FullName }
Expected result: C:\app\data\backend\mediastore\seaweedfs\storage-owner.json exists, and the environment of each service holds the values of the set.
5. 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.
Expected result:
- the login page opens and the
adminaccount signs in; - an existing conversation opens;
- a document uploaded before the backup downloads.
Special cases
Restore on a new server
On a single server, the node identity derives by default from the network card, and the built-in storage refuses a disk marked by another node. Before step 5, read the node_id value in storage-owner.json, then add SMARTAGT_NODE_ID=<value read> to the environment of the Backend services: /etc/smartagt/backend.env on Linux, the services environment on Windows.
On Linux, also enable the restored services, whose startup links are not in the set: sudo systemctl enable followed by the installed services.
Replace the certificate of your listeners if it carries the name of the former server: Install your certificates.
Built-in storage messages at startup
| Message | Cause |
|---|---|
Le manifeste diffère de la topologie acceptée. Restaurer le manifeste de cette installation avant le redémarrage. |
Different node identity, see the previous case |
Le disque appartient à un autre nœud ou une autre installation. |
mediastore/seaweedfs directory from another installation or another set |
Le disque d'un ancien membre est absent ; sa reprise automatique est refusée. |
Database restored without the mediastore/seaweedfs directory |
Les volumes d'un ancien membre sont absents ; utiliser la maintenance de stockage. |
Directory restored without its volumes |
Frontend restored alone or newer Backend
If the Frontend reports backend_key_changed, run the Frontend Initialize step again with --adopt-backend-key, then restart its service.
S3 storage
Restore the bucket with your tools at the same point as the databases, before step 5. Step 4 then contains no mediastore/seaweedfs directory.