feat: [US-003] Audit and document deploy script data preservation
- Add detailed logging in Deploy-Backend function for data/ preservation - Update deployment/windows/README.md with "Data Preserved During Deploy" section - Document data/ directory structure (receipts/, telegram/, cache/) - Explain preservation mechanism (backup → deploy → restore) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -154,6 +154,56 @@ deploy.sh (Linux) │
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Data Preserved During Deploy
|
||||||
|
|
||||||
|
During deployment, the following are **automatically preserved** (not overwritten):
|
||||||
|
|
||||||
|
### Files Preserved
|
||||||
|
|
||||||
|
| Item | Location | Description |
|
||||||
|
|------|----------|-------------|
|
||||||
|
| `.env` | `backend/.env` | Environment configuration |
|
||||||
|
| `data/` | `backend/data/` | All SQLite databases and uploads |
|
||||||
|
|
||||||
|
### Data Directory Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
backend/data/
|
||||||
|
├── receipts/ # Data Entry module
|
||||||
|
│ ├── receipts*.db # SQLite database (bonuri, aprobări, workflow)
|
||||||
|
│ └── uploads/ # User-uploaded files (PDF/images)
|
||||||
|
├── telegram/ # Telegram Bot module
|
||||||
|
│ └── telegram*.db # Bot auth/session data
|
||||||
|
└── cache/ # Reports module
|
||||||
|
└── roa2web_cache*.db # L2 cache (can be regenerated)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Preservation Mechanism
|
||||||
|
|
||||||
|
The `ROA2WEB-Console.ps1` script:
|
||||||
|
|
||||||
|
1. **Before deploy**: Copies `data/` to `%TEMP%\roa2web-data-backup-*`
|
||||||
|
2. **During deploy**: Deletes and replaces entire `backend/` folder
|
||||||
|
3. **After deploy**: Restores `data/` from backup
|
||||||
|
|
||||||
|
**Safe to lose** (regenerated automatically):
|
||||||
|
- `cache/*.db` - Reports cache, rebuilt on first query
|
||||||
|
|
||||||
|
**Critical data** (must be preserved):
|
||||||
|
- `receipts/*.db` - User data, approvals, workflow states
|
||||||
|
- `telegram/*.db` - Bot authentication tokens
|
||||||
|
|
||||||
|
### Manual Backup
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
# Create manual backup before major operations
|
||||||
|
Copy-Item -Path "C:\inetpub\wwwroot\roa2web\backend\data" `
|
||||||
|
-Destination "C:\backups\roa2web-data-$(Get-Date -Format 'yyyyMMdd')" `
|
||||||
|
-Recurse
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
| Problemă | Verificare | Soluție |
|
| Problemă | Verificare | Soluție |
|
||||||
|
|||||||
@@ -817,7 +817,10 @@ function Deploy-Backend {
|
|||||||
$dataTempPath = Join-Path $env:TEMP "roa2web-data-backup-$(Get-Date -Format 'yyyyMMddHHmmss')"
|
$dataTempPath = Join-Path $env:TEMP "roa2web-data-backup-$(Get-Date -Format 'yyyyMMddHHmmss')"
|
||||||
$dataBackup = $null
|
$dataBackup = $null
|
||||||
if (Test-Path $dataDir) {
|
if (Test-Path $dataDir) {
|
||||||
Write-Info "Preserving data directory (SQLite databases, uploads, cache)"
|
Write-Info "Preserving data directory: receipts.db, telegram.db, cache, uploads"
|
||||||
|
Write-Info " - receipts/: Data Entry SQLite database (receipts, approvals)"
|
||||||
|
Write-Info " - telegram/: Telegram bot auth/session database"
|
||||||
|
Write-Info " - cache/: Reports L2 cache database"
|
||||||
Copy-Item -Path $dataDir -Destination $dataTempPath -Recurse -Force
|
Copy-Item -Path $dataDir -Destination $dataTempPath -Recurse -Force
|
||||||
$dataBackup = $dataTempPath
|
$dataBackup = $dataTempPath
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user