Files
ims/docs/runbooks/cleanup-test-data.md
T
2026-10-14 11:14:57 +08:00

1.3 KiB

Cleanup: delete test incidents and non-admin users

Owner go-ahead required before step 4. Never run during business hours without telling HSE.

  1. Backup (on the server, ssh -p 9321 setia@175.136.239.121):
    D=$(date +%Y%m%d-%H%M)
    pg_dump -p 5433 -Fc ims > /srv/apps/ims/backups/ims-pre-cleanup-$D.dump
    tar -czf /srv/apps/ims/backups/evidence-pre-cleanup-$D.tgz /var/lib/ims-evidence
    ls -lh /srv/apps/ims/backups/*pre-cleanup-$D*
    
    Create /srv/apps/ims/backups first if missing. Both files must be non-empty.
  2. Upload db/ops/cleanup-test-data.sql to /srv/apps/ims/backups/ (not into app/).
  3. Dry run as the DB owner:
    psql -p 5433 -d ims -v mode=dryrun -f /srv/apps/ims/backups/cleanup-test-data.sql
    
    Send the admins list and the row counts to the owner. Stop here until they confirm.
  4. Run after explicit confirmation:
    psql -p 5433 -d ims -v ON_ERROR_STOP=1 -v mode=run -f /srv/apps/ims/backups/cleanup-test-data.sql
    
  5. Verify: systemctl is-active ims is active; log in as an admin at https://ims.setia.com.my/login; Incidents page is empty; Users page lists only admins.
  6. Rollback (only if wrong): pg_restore -p 5433 -d ims --clean --if-exists <dump>; evidence files were never touched.