Skip to content

feat: DB-based round backups, restore voting system, and multi-server isolation - #398

Open
hznovich wants to merge 3 commits into
shobhit-pathak:devfrom
hznovich:feature/db-backups-and-restore-voting
Open

hznovich wants to merge 3 commits into
shobhit-pathak:devfrom
hznovich:feature/db-backups-and-restore-voting

Conversation

@hznovich

Copy link
Copy Markdown

What this does

1. Database-backed round backups

Round backups are now stored in the database (SQLite or MySQL) instead of JSON files on disk. The matchzy_backups table stores all backup metadata including the Valve backup payload.

  • New table matchzy_backups for both SQLite and MySQL schemas
  • SaveRoundBackup() writes directly to DB
  • RestoreRoundBackup() reads from DB with legacy filename fallback
  • GetBackups() / GetBackupInfo() use DB queries

2. Restore voting system

Non-admin players can now initiate a vote to restore a match from backup — useful when the server crashes and players reconnect.

  • .restore starts a vote (available to all players when match is not live)
  • Players vote via .yes / .no in chat
  • 75% threshold, 20-second timeout
  • On pass: shows 5 most recent backups from DB, player picks with .restore <id>
  • Admin-only .restore unchanged when match is live

3. Multi-server isolation via matchzy_server_id

New ConVar matchzy_server_id — set per-server in server.cfg:

matchzy_server_id "moscow-bo1"
  • Backups are tagged with server_id in the DB
  • All queries filter by server_id when set
  • Empty value = no filtering (backward compatible)

Files changed

  • DatabaseStats.cs — new table, BackupRecord class, 5 CRUD methods
  • BackupManagement.cs — DB-backed backup/restore, voting system (StartRestoreVote, OnRestoreVoteYes/No, ShowBackupListForVote)
  • MatchZy.cs.yes/.no commands, .restore → voting flow
  • ConfigConvars.cs — new matchzy_server_id FakeConVar
  • lang/en.json + lang/ru.json — 13 localization strings for voting

Backward compatibility

  • Empty matchzy_server_id = no filtering (existing servers work)
  • RestoreRoundBackup falls back to old filename format if not found in DB
  • Existing file-based backup code path preserved (can be re-enabled)

All changes tested for compilation compatibility with CounterStrikeSharp API.

hznovich added 3 commits July 26, 2026 21:27
- Add matchzy_backups table to SQLite and MySQL (Database.cs)
- Write round backups to DB instead of JSON files (BackupManagement.cs)
- Read backups from DB, with legacy filename fallback
- Add restore voting: .restore starts a vote, .yes/.no, 75% threshold
- Vote timeout 20s, shows 5 most recent backups on pass
- Non-admin players can .restore when match is not live (after crash)
- Admin-only .restore unchanged when match is live
- ru/en localization for all vote messages
- New ConVar: matchzy_server_id (set per-server in server.cfg)
- Added server_id column to matchzy_backups table (SQLite + MySQL)
- All backup queries now filter by server_id when set
- ShowBackupListForVote shows only this server's backups
- Empty value = no filtering (backward compatible)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant