1.3 KiB
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.
- Backup (on the server,
ssh -p 9321 setia@175.136.239.121):CreateD=$(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*/srv/apps/ims/backupsfirst if missing. Both files must be non-empty. - Upload
db/ops/cleanup-test-data.sqlto/srv/apps/ims/backups/(not intoapp/). - Dry run as the DB owner:
Send the admins list and the row counts to the owner. Stop here until they confirm.
psql -p 5433 -d ims -v mode=dryrun -f /srv/apps/ims/backups/cleanup-test-data.sql - 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 - Verify:
systemctl is-active imsisactive; log in as an admin at https://ims.setia.com.my/login; Incidents page is empty; Users page lists only admins. - Rollback (only if wrong):
pg_restore -p 5433 -d ims --clean --if-exists <dump>; evidence files were never touched.