|
- @echo off
- rem Restores the SQLite database from a backup made by scripts\backup.cmd. Run from the repo root.
- rem
- rem scripts\restore.cmd db/backups/app-YYYYMMDD-HHMMSS.sqlite
- rem
- rem 1. stops the HTTP server and the embed worker (nothing may write during the copy)
- rem 2. verifies the backup (integrity_check, foreign keys, migrations); if it fails nothing is changed
- rem 3. keeps the current database as db\backups\pre-restore-<timestamp>.sqlite and copies the backup over it
- rem 4. starts the server and the worker again, then rebuilds the vector index from the restored data
- rem (Qdrant is derived data and may hold vectors for rows the backup does not have)
- rem If the restored schema is older than the code, run scripts\migrate.cmd up afterwards.
- setlocal
- if "%~1"=="" (
- echo Usage: scripts\restore.cmd db/backups/^<file^>.sqlite
- exit /b 1
- )
- docker compose stop axonasp embed-worker || exit /b 1
- docker compose run --rm --no-deps -T -e SERVER_WEB_ROOT=/opt/axonasp/site -e BACKUP_ACTION=restore -e "BACKUP_FILE=%~1" axonasp ./axonasp-cli -r /opt/axonasp/site/scripts/backup.asp > "%TEMP%\amk-restore.log"
- set RC=%errorlevel%
- type "%TEMP%\amk-restore.log"
- docker compose start axonasp embed-worker
- findstr /b /c:"RESULT: ok" "%TEMP%\amk-restore.log" >nul
- if errorlevel 1 (
- echo Restore FAILED, see the messages above. If the backup did not verify, nothing was changed; if the copy
- echo had started, the previous database is in db\backups\pre-restore-^<timestamp^>.sqlite.
- exit /b 1
- )
- call "%~dp0embed.cmd" reindex
- exit /b 0
|