docs for auto backup production db.
This commit is contained in:
@@ -96,6 +96,8 @@ Errors: `AppException` + `ErrorCode` → frontend `getUserFacingError()`. Unexpe
|
||||
|
||||
**AdminJS:** Manual resource allowlist in `backend/src/admin/resources.ts`. **Whenever `schema.prisma` changes**, update AdminJS resources in the same task (new/renamed/removed models, hide secrets). Models with only composite `@@id` must not be registered (list 500) — including `LabCaseAttachment`. Single-id models such as `StaffWorkingHoursSchedule` / `StaffWorkingHoursBlock` **are** registered. `LabCase.listedAt` is trigger-maintained (list/filter/show only; never write). Rule: `.cursor/rules/adminjs.mdc`.
|
||||
|
||||
**Database backups:** Production dumps three times a day on the Linux server and keeps them for 3 days. The Mac copies them once at 17:00. The Windows staging PC copies each dump 30 minutes later and keeps them for 30 days (task **Nudentic copy prod backup**). Runbook: [`infrastructure/BACKUP.md`](infrastructure/BACKUP.md).
|
||||
|
||||
## Git & commits
|
||||
|
||||
- **Do not commit or push** unless the user explicitly asks.
|
||||
|
||||
@@ -193,14 +193,35 @@ Register-ScheduledTask -TaskName 'Nudentic copy prod backup' -Action $action -Tr
|
||||
|
||||
If `Get-Date` shows UTC (`+00:00`), production’s jobs are 22:30, 07:30, and 12:30 UTC. Use **23:00**, **08:00**, and **13:00** in `$triggers` instead.
|
||||
|
||||
Try it once before relying on the schedule:
|
||||
### Already on the staging PC
|
||||
|
||||
The task name is **Nudentic copy prod backup**. [`scripts/copy-prod-backup.ps1`](scripts/copy-prod-backup.ps1) only copies files. It does not create this task. Creating it is the `Register-ScheduledTask` block above, run once on the PC.
|
||||
|
||||
On the staging PC it is already registered as `Administrator`. The clock there is Iran time (`+03:30`), and the triggers are 02:30, 11:30, and 16:30. Running that block again replaces the same task.
|
||||
|
||||
See it:
|
||||
|
||||
```powershell
|
||||
Get-ScheduledTask -TaskName 'Nudentic copy prod backup' | Format-List TaskName, State
|
||||
Get-ScheduledTaskInfo -TaskName 'Nudentic copy prod backup' | Format-List LastRunTime, LastTaskResult, NextRunTime
|
||||
```
|
||||
|
||||
`State: Ready` means it is scheduled. `LastTaskResult` **267011** and a `LastRunTime` in 1999 mean it has never run. **0** means the last copy finished.
|
||||
|
||||
Run it now without waiting for the next clock time:
|
||||
|
||||
```powershell
|
||||
Start-ScheduledTask -TaskName 'Nudentic copy prod backup'
|
||||
```
|
||||
|
||||
Then read `C:\dyolink\nudentic-backups\copy.log`. A good line says `Copied nudentic_….dump`. A second run says `Already present`. The first run also stores the production host key in `known_hosts` in that folder. A `.dump` larger than a few kilobytes in `C:\dyolink\nudentic-backups` is a good file.
|
||||
|
||||
You can also run the script by hand:
|
||||
|
||||
```powershell
|
||||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\dyolink\scripts\copy-prod-backup.ps1
|
||||
```
|
||||
|
||||
A good run writes a `.dump` larger than a few kilobytes into `C:\dyolink\nudentic-backups` and a line in `C:\dyolink\nudentic-backups\copy.log`. The first run also stores the production host key in `known_hosts` in that folder. Run it again. The log should say each file is already there.
|
||||
|
||||
---
|
||||
|
||||
## 3. Load the dump into the local database
|
||||
|
||||
Reference in New Issue
Block a user