Tới nội dung
DBA Brain

DBA Brain miễn phí để cài đặt và sử dụng. Bạn cần một DBA - migrate sang engine khác, backup, performance tuning?

Chúng tôi làm gì

Chúng tôi làm gì

DBA Brain miễn phí để cài đặt và sử dụng, theo Apache License 2.0. Ngoài công cụ, bạn có thể liên hệ với chúng tôi về các công việc DBA khác, chẳng hạn như những việc dưới đây. Hãy gửi email hoặc gọi điện để cho chúng tôi biết bạn cần gì.

  • Migrate database sang engine khác - từ SQL Server hoặc Oracle sang PostgreSQL hoặc MySQL
  • Upgrade version và patching
  • Backup và restore: chiến lược, setup, restore drill, recovery
  • Performance: query chậm, index, plan
  • Health check và monitoring, kèm alert
  • High availability và replication
  • Security: login, phân quyền, mã hoá
  • Setup và config DBA Brain trên server của bạn
  • Tư vấn cho hệ thống database, và hỗ trợ DBA hằng ngày
Tính năng

Verdict đã được grade, không phải raw data

Health metric từ các instance SQL Server, Oracle, PostgreSQL và MySQL của bạn, grade theo policy bạn viết; SQL của bạn chạy theo schedule; backup được verify bằng cách restore thật; objective được kiểm tra dựa trên lịch sử đo thực tế. Không telemetry, không usage report, không update check. DBA Brain kết nối tới các database và host bạn liệt kê; nếu có dbabrain key, mỗi ngày một lần tới dbabrain.dev để kiểm tra key đó; và chỉ khi bạn bật từng thứ, tới một dịch vụ chat và tới AI (qua dbabrain.dev, hoặc API của một model bằng key của riêng bạn). Ngoài ra không gì khác.

Backup được verify bằng restore

Chạy backup, restore lên một disposable target, verify kết quả và ghi lại đã chứng minh được gì, vào lúc nào. Chính lần restore là bằng chứng. Từng bước.

Health metric

Khoảng chín mươi metric trên các engine được hỗ trợ: availability, capacity, performance, recoverability, security, maintenance. Được thu thập và chuẩn hoá về cùng một dạng.

Alert và lệnh chat

Gửi qua Telegram, từng tin nhắn một. Lệnh người dùng gửi lại được kiểm soát theo quyền của người đó và quyền của nhóm chat.

Đã grade, không đổ raw data

Mọi phép đo đều được grade theo policy bạn viết. Bạn đọc một verdict (OK, WARNING, CRITICAL) và chỉ lấy bằng chứng cho những gì có vấn đề.

SQL chạy theo schedule

SQL của chính bạn, chạy theo schedule hoặc theo yêu cầu, trên các target đã được duyệt, gửi về dạng text hoặc spreadsheet. SQL là một file có thể review, không bao giờ là một chuỗi trong config. Một thao tác write ad-hoc (run-sql-adhoc) sẽ bị rollback trừ khi request ghi rõ commit; khi node yêu cầu hai lần xác nhận cho một thao tác write hoặc một command, lần xác nhận thứ hai là gõ lại server_id của target (confirm_target).

Report

Fleet inventory, metric theo từng server, index usage và các trang SLA, kèm freshness gate để một số liệu cũ không bao giờ được đưa vào report như số liệu hiện tại.

SLA / SLO

Indicator được tính từ lịch sử đo đã lưu, objective được đánh giá theo error budget, kèm phần error budget còn lại.

Config as code

Mọi quyết định là một file JSON bạn quản lý trong version control. Đổi một ngưỡng là một diff và một lượt review, không phải sửa script của ai đó. Một server không còn dùng nữa cũng được gỡ theo cách đó: entry-remove, credential-remove, instance-remove và report-server-remove mỗi lệnh gỡ một bản ghi, tầng sâu nhất trước, bị từ chối khi còn chỗ nào tham chiếu tới nó (liệt kê đủ mọi chỗ), và chỉ là một plan trừ khi được yêu cầu apply.

Secret luôn được mã hoá

PBKDF2-HMAC-SHA256 + Fernet. Passphrase được cung cấp lúc chạy và không bao giờ được ghi ra đĩa, log hay store. Mật khẩu đi qua stdin, không bao giờ qua argv. secret-remove gỡ một secret, được verify bằng chính giá trị nó đang giữ, và bị từ chối khi còn login hoặc entry nào tham chiếu tới nó.

Trợ lý AI (tuỳ chọn)

Hỗ trợ hằng ngày cho DBA và DevOps engineer, trên các database và server mà dbabrain monitor. Hỏi trong Telegram hoặc tại terminal (dbabrain telegram ai-ask) - vì sao alert này bật, backup đêm qua có chạy không, job nào bị lỗi, server này chậm ở đâu, query nào bị regression - và trợ lý tự tìm câu trả lời: metric, các lần chạy, backup và restore trong store của dbabrain, config và log, một query read-only trên server. Trợ lý phân tích query - nặng nhất theo CPU, reads và duration, plan ad-hoc và plan single-use, plan regression và plan change (Query Store) - và index (usage, unused, fragmented, invalid). Trợ lý giải thích những gì tìm thấy và việc cần làm, đưa ra đúng lệnh cho bước tiếp theo (một dòng CLI hoặc một lệnh /spbot_), kể cả chạy backup hay restore thủ công. Trợ lý cũng hướng dẫn một bản cài mới qua các bước setup. Trợ lý chỉ đọc và đề xuất; mọi thứ làm thay đổi hệ thống đều do một người chạy. Trợ lý trả lời khi node của bạn có dbabrain key miễn phí (dbabrain key-request), qua dbabrain.dev - hoặc bằng Anthropic key của riêng bạn (dbabrain ai-key); mọi câu hỏi, tool call, token và chi phí đều được lưu lại, trong giới hạn bạn đặt.

MCP server cho AI agent

Mọi thao tác dùng chung và runtime store đều là MCP tool, giữ nguyên gate riêng của từng lệnh, mọi câu trả lời đều được ẩn thông tin nhạy cảm và giới hạn kích thước. Không secret nào đi vào qua MCP, và không secret nào đi ra.

DBA Brain không phải là

Không phải một AI tự vận hành hệ thống của bạn

DBA Brain là harness để một model AI làm việc qua đó: tốt hơn khi có AI, vẫn đầy đủ khi không có. Scheduler, việc grade, backup và alert là code và SQL đã review; không phần nào cần đến model. Trợ lý tích hợp sẵn (tuỳ chọn), cho công việc hằng ngày của DBA và DevOps engineer (tên khi release là Phanes; mỗi bản cài có thể đổi tên bằng assistant_name trong ai_assist.json), trả lời qua dbabrain.dev khi node có dbabrain key (hoặc bằng Anthropic key của riêng bạn), đọc qua các tool read-only, và đề xuất lệnh để một người chạy.

Không phải một sản phẩm dashboard

Giao diện chính là CLI; đầu ra chính là một bản ghi trong database do bạn sở hữu.

Không cài gì lên database của bạn

Không agent, không extension, không stored procedure. Metric chỉ cần một login read-only để query; backup, restore và các lệnh làm thay đổi hệ thống dùng một login có đủ quyền cho các thao tác đó.

Reports

What it produces

Real report pages from a live estate, with every name replaced by a stable fake one. Open an image to see it full size.

Fleet inventory and health report: server counts per engine, critical findings ordered by severity with a recommended action
Fleet inventory: every instance, its health, and a priority list of what to act on first, each with a recommended next step.
Per-server metrics page: health score, status cards for availability, CPU, memory, disk, backup and security, and a list of problems
Server metrics: one card per health area, showing the worst reading, the rule that graded it and what it means.
SLA / SLO compliance page with overall verdict and per-engine cards
SLA / SLO compliance: verdict per engine, computed from stored history with no database connections.
Index usage report for one SQL Server instance: total, unused, cold and droppable indexes
Index usage: total, unused, cold and droppable indexes per instance, with how long the counters cover.
How it works

One run, end to end

Whoever starts it (the daemon, a person, a chat command or an AI agent), a run takes the same path. The app hands one JSON request to transport, which starts the shared operations CLI; that CLI reaches the database or host and answers with one JSON envelope. Results land in the runtime store, and reports and alerts are built from there.

Scroll sideways to see the whole diagram.
CALLERS APP SHARED LAYERS YOUR ESTATE Daemon (schedule) Person (shell) Chat command AI agent App CLI metrics sql_tasks backup_restore sla · reports sre · control one JSON object in, one JSON object out transport starts process common.cli JSON on stdin SQL Server Oracle PostgreSQL MySQL / MariaDB Linux / Windows read-only login, SSH or WinRM job_runs, measurements Runtime store SQLite or PostgreSQL Reports Web host :8080 Telegram alerts

The same envelope, every time

Every command answers in the same envelope, whether the work succeeded or not: seven keys that are always present, so a person, a script and an agent read a result the same way.

json
{
  "success": true,
  "operation": "restore-full",
  "message": "Restored SALESDB_STG to 2026-08-07 01:40:00.",
  "error": null,
  "error_kind": null,
  "data": { },
  "metrics": { "duration_ms": 41230 }
}

From a measurement to an alert

  1. Collectabout ninety metrics across every engine
  2. Normaliseone shape for all engines
  3. Gradeagainst your policy in data/*.json
  4. Storein the runtime store
  5. Report, alert, SLAby severity and error budget

A backup is proven by restoring it

  1. Backupfull / diff / log
  2. Copyto a disposable target
  3. Restorelatest or point in time
  4. Verifythe result
  5. Recordwhat was proven, and when
  6. Clean upand apply retention

Why: cheap for an AI agent, fine without one

The command a person runs is byte-for-byte the command an agent runs, so there is one code path to audit, and every run is logged the same way whoever started it.

The saving is not compression. It is not sending what nobody needed to read. And no model is required: remove the agent and the daemon, schedules, reports and alerts all still run.

  WITHOUT a tool                  WITH DBA Brain
  agent -> raw SQL -> agent       agent -> DBA Brain -> database

  "check this database"           "check this database"
    -> SELECT ... dm_os_wait_stats  -> one JSON request
    <- every row, into the context
    -> SELECT ... sys.databases     <- one graded envelope:
    <- every row, into the context       41 checks, 40 OK,
    -> ... once per check, per run       1 WARNING: appdb
    <- all of it, healthy or not         log backup 31h old

With and without DBA Brain: four DBA tasks an AI agent did

Four tasks from the week version 0.41.0 soaked, each done by an AI agent working for a DBA. The agent and the databases were the same either way; what differs is what the agent has to hold, guess and read.

TaskWithout DBA BrainWith DBA Brain
The same linked-server query works on one SQL Server and fails on another The agent needs a connection string and a password for each instance, pasted into its context or a script; it guesses a driver and an encryption setting per version (an old 2008 R2 and a 2017 here); the error comes back as a driver's text to parse. One request per instance names its server_id; the inventory fills the connection, the secret store the password - the agent never sees one. The driver and encryption are chosen and reported (target_profile: version, OS, driver). The two instances' linked-server settings and provider versions were compared in a few read-only requests; the failing one had a provider build from before TLS 1.2 support.
A sync procedure returns nothing while the source system has the data Read the procedure, rebuild its dynamic SQL by hand, run each step against the remote system over a linked server; any write the agent tries to test lands for real. run-sql-adhoc rolls back unless told to commit, so the procedure's own body was run as is and with one join changed - 0 rows, then every row - before anything was altered. The change itself was committed only after a typed yes, with the reason recorded; the definition before and after was kept.
A query is slow, or a server was slow since yesterday Query sys.dm_exec_requests, wait stats and the plan cache now; what happened yesterday is gone unless someone was watching. Each check is a result set the agent reads in full. The metrics are already collected on a schedule and kept: long-running and blocking sessions, waits, top queries by CPU / elapsed / reads, Query Store regressions, I/O latency - each graded OK / WARNING / CRITICAL, with history. The agent asks "since when" of the store, reads the graded verdict, and pulls the evidence only for what is not OK. trace-session names who holds an open transaction.
Is this server's workload heavy, and what drives it? Sample counters a few times, by hand, and extrapolate; the numbers depend on when they were taken. The report's per-server page carries the Workload section: CPU (the engine's and the host's), batches, transactions, compilations, reads and writes, waits, log by database, top queries - from the same history. The agent reads one page or one store query instead of sampling.

What does not change: DBA Brain does not decide the fix. It gives the agent a connection it does not hold, a verdict instead of raw rows, a history it did not have to collect, and a write path that is rolled back unless a person says yes. Every run, the agent's included, is a row in job_runs and a line in a log, so what the agent did is the same query as what the daemon did.

How a model reaches your estate: no public IP, no inbound port, no server

In every way below the connection is opened from your machine, outward. Nothing on the internet connects in, and the commands run on your machine with your credentials.

WayWhat runs whereWhat the network needs
The assistantkey-request, then dbabrain telegram ai-ask or Telegram Your node sends the question to dbabrain.dev, which passes it to the model's API (or, with ai-key, straight to the API on your own Anthropic key); the model answers with the dbabrain tools it wants run; your node runs them (read-only) and sends the results in the next request, until the model answers. Outbound HTTPS to mcp.dbabrain.dev:443 (with ai-key: api.anthropic.com:443; through http_proxy in data/ai_assist.json when you need one). Telegram is polled outbound (getUpdates to api.telegram.org:443): no webhook.
An AI app on the same machineClaude Desktop, Claude Code, any MCP client The app starts dbabrain mcp serve as a child process and talks to it over stdin/stdout. Nothing from dbabrain; the app talks to its own model.
claude.ai on the web or a phone dbabrain mcp connect links your node to the remote connector at mcp.dbabrain.dev and keeps one WebSocket open from your node; claude.ai's requests come down it. Outbound HTTPS/WebSocket to mcp.dbabrain.dev:443. The public endpoint is dbabrain.dev's, not yours.

Only dbabrain mcp serve --http, serving MCP yourself, needs an address others can reach, and it is behind a bearer token.

No secret enters through MCP, and none leaves

A request carrying a password, a key or a token is refused before it runs. The person types secrets on the node (dbabrain common secret-set -, dbabrain ai-key) and the model names them by reference (password_ref). A login the node completes from its own encrypted store is not such a secret: the model names the server_id. Every answer is redacted before the model reads it.

Backup & restore

A backup that outlives the host it came from

A backup kept on the database host is lost together with it. A dead disk takes the database and every backup written next to it, so a backup on the same disk as the database is one of the biggest holes there is. A lost host, or any other failure of that machine, takes every disk it has. Ransomware goes further: it encrypts every drive and every share the infected host can write to.

DBA Brain proves every backup at each step, keeps a proven copy away from the database host, and can keep that copy encrypted there.

Scroll sideways to see the whole diagram.
DATABASE HOST DBA BRAIN (ANOTHER HOST) REPOSITORY (OUTSIDE THE DB HOST) RESTORE TARGET 1 · Backupverified by the engine 2 · Hash at the sourceSHA-256 + size in bytes 3 · Re-check on diskscrub + ransom markers Catalogthe first hash can neverbe changed 8 · History, reportsper file, per restore copy 4 · Copyhash + bytes, copy again 5 · Encrypt (age)decrypted back to prove it 6 · Mark verifiedonly then may the source go delete the source: optional, off by default 7 · Restore drill only from proven copies: restored, opened, checked, latest or a point in time the run and every file it applied, in order

Every box is a step DBA Brain runs and records. The dashed line is optional: deleting the source is a switch per entry, off by default.

Each backup run, step by step

FULL, DIFF and LOG backups for SQL Server; a base backup plus WAL for PostgreSQL; RMAN for Oracle. Every level says the same ten steps, one message each; which of them reach a chat is the job's notify.

  1. Backup process startedthe level, the time, and a line of the steps it runs; a step the entry has off is said off
  2. Backup on the server startedon the database host
  3. Backup on the server doneverified by the engine, hashed at the source; an Oracle backup records its RMAN chain
  4. Copy to the repository startedright after the backup, in the same pass
  5. Copy to the repository doneproven by checksum and bytes; the instance's metadata carried too, sealed
  6. Encrypt startedwith age, on the repository
  7. Encrypt doneor waiting while an earlier pass's encryption still runs: not a failure
  8. Plain files clearedthis backup's, at the source and on the repository
  9. Repository upkeep doneearlier backups released, retention, late encryption, the check
  10. Backup process doneor FAILED at step N, with why

A backup with nothing for a repository says 1, 2, 3 and 10. A later pass takes only what a backup left (a copy to try again, files past offload_files_per_pass, an encryption still running) and says its steps the same way. Each step says what it read, not what it assumed: step 8 counts the files deleted and kept, step 9 says each part's work, nothing or off.

What every backup is held to

Verified by the engine

SQL Server RESTORE VERIFYONLY WITH CHECKSUM, PostgreSQL pg_verifybackup, Oracle RMAN VALIDATE. An Oracle backup states its SID (oracle_sid) and is held to the instance that answers before RMAN runs; after each run it records its RMAN chain (record_chain). A PostgreSQL base backup is catalogued file by file.

Hash at the source

SHA-256 and size in bytes, taken on the database host when the backup ends and stored in the catalog on another host. The first hash can never be changed, not even by a direct UPDATE: a database trigger refuses it.

Re-check stored files

After every backup run, older files of its entry are hashed again, those checked longest ago first, so within days every stored file has been re-read: ransomware encrypts last week's backups, not tonight's. A changed file shows CHANGED, a vanished one MISSING, and the alert is CRITICAL. By hand: verify-backup-files.

Look for ransomware markers

After each run the backup folder is listed for what ransomware leaves: ransom notes such as read-me*.txt, locked-file names such as *.L0CK3D or *.locked. A hit is CRITICAL and engages the lockdown. A new file three times the size of its history, or a third of it, is a WARNING.

Copy to the repository

Right after each backup, in the same pass, its files are copied to a Linux host outside the database host, over SSH. The source is held to its backup's checksum, the copy is hashed there and compared by checksum and bytes, and copied again on a mismatch up to offload_copy_max_retry; every attempt is recorded.

Encrypt it there

With offload_encrypt, each file is encrypted with age for the key's public half only, so the repository cannot decrypt what it holds. The .age file is streamed back and decrypted, and held to the backup's bytes and SHA-256, before the plain copy goes. One key ring per server; a key encrypts for a stated number of days and decrypts for ever.

Verified, then the source may go

Only a copy proven, and wholly encrypted when the entry encrypts, may release the source, and it is hashed again just before. Each file is deleted by its own command, held to its recorded size and SHA-256. A switch per entry, off by default, and never during a lockdown.

The lockdown

Engaged by three or more stored files changed or gone, or by a ransomware marker; only a person turns it off, with a note (dbabrain control lockdown, or /spbot_lockdown in Telegram). While it is on nothing is pruned, deleted or replaced; backups, the scrub and alerts keep running.

Each restore, step by step

On a schedule or by hand, onto the target the entry names. A dry run first says what it would copy, where each database lands and what would refuse it. A restore says eleven steps, the same numbers on every engine; which of them reach a chat is the entry's notify.

  1. Restore process startedwith a line of the steps it runs
  2. Copy to the targetstarted and done; decrypted on the way from the repository
  3. Instance metadata before the restoreor not restored, with why
  4. Certificaterestored, or none, with why
  5. Restore fulla start and a done per database
  6. Restore diffa start and a done per database, or none, with why
  7. Restore logone message per file; skipped or FAILED, with why
  8. Checkstarted and done
  9. Instance metadata after the restorereplayed after the check
  10. Plain files clearedthe decrypted copies on the target
  11. Restore process doneor FAILED at step N, with the engine's words

A step that does not apply is still said, with why. On PostgreSQL step 5 is the base backup (its incrementals combined) and on Oracle the RMAN duplicate, with 6 and 7 said inside it; 3, 4 and 9 are said as not applying, because their logins are inside the physical backup and there is no certificate step. A restore in place says 2 and 10 as not applying; a copy-only run says 1, 2 and 11.

What every restore is held to

From the repository, or the source

SQL Server, PostgreSQL and Oracle restore from the repository's proven copies (restore_from: "repository"), decrypted on the way, or from the source server. Only the chain that reaches the moment asked is copied, and every staged file is held to its recorded checksum and bytes. An Oracle restore takes the RMAN chain its backup recorded, newest or to a moment, and is refused before anything is copied when a piece of it is missing.

Latest, or a point in time

On SQL Server, PostgreSQL and Oracle, wherever the logs cover the moment: transaction log backups, WAL, archived logs. On Oracle and PostgreSQL the moment is read in the source database's own clock, asked of it, and refused when that clock cannot be known: never assumed UTC. A SQL Server restore is held to where it was asked to stop: the target's own restore history is read back, and a difference fails the restore.

The instance around the databases

A backup can seal the instance's metadata (logins, jobs, configuration) into the repository with age, so the repository never holds it in the clear. A restore reads it from the node, a server's folder or the repository, as its entry says, and replays it before and after the databases (steps 3 and 9). A bundle that cannot be had skips the phase with why and never loses the restore.

Nothing replaced unless stated

overwrite_existing is required on every restore entry, true or false. With false a restore never replaces an existing database: SQL Server stops on a database of that name in any state, PostgreSQL on a data directory that holds a cluster of its own, Oracle on a database that holds its own schemas.

Opened and checked

A restore is not done until the restored databases open to a real query, and the engine's own consistency check runs on them (checkdb): DBCC CHECKDB, pg_amcheck, RMAN VALIDATE. A SQL Server restore that failed part way can be continued after the last backup the target applied.

Every file recorded, in order

Every backup file a restore applied (the full, the differential, each log) is recorded in the order it went in, written before the first step runs, so a restore that dies leaves the chain it meant to apply. The backup page and each server page list the restores and their files.

Onto SQL Server on Windows

A restore from the repository onto SQL Server running natively on Windows, over the host's OpenSSH: free space read by PowerShell, files written over SFTP to a staging folder on a drive path, and the verified deletes run there too.

Not built, or not run yet: a PostgreSQL or Oracle restore under another name (RENAME / DUPLICATE TO; an entry mapping a name for those engines is refused); a point in time on Oracle or PostgreSQL from a source not on UTC, not yet run on a host; a restore through MCP (restore-by-id runs on the node). After a PostgreSQL or Oracle restore the target's logins are the source's: the whole instance is the source's, and the target's stored password logs in again only once it is set again.

Configuration

Every field that decides a backup or a restore is stated, so nothing is left to a default nobody wrote down. upgrade-config writes into existing entries the values they have been running on, such as offload_enabled: false, offload_delete_source: false and restore_from: "server", and overwrite_existing: false, never true: an entry meant to replace a database states true itself. It cannot know an Oracle entry's oracle_sid: an entry without one is refused, naming the field.

json
{
  "backups": [
    {
      "backup_id": "APPDB_FULL",
      "server_id": "db-server",
      "jobs": [
        { "job": "database", "databases": ["APPDB", "SALESDB"], "all_databases": false },
        { "job": "log", "databases": [], "all_databases": true }
      ],
      "offload_enabled": true,
      "offload_server_id": "repository-vm",
      "offload_folder": "/srv/backups",
      "offload_copy_max_retry": 3,
      "offload_encrypt": true,
      "offload_encrypt_key_days": 90,
      "offload_delete_source": false,
      "offload_source_share": "",
      "offload_source_username": "",
      "offload_source_password_ref": ""
    }
  ],
  "restores": [
    {
      "restore_id": "APPDB_TO_DRILL",
      "server_id": "db-server",
      "target_server_id": "drill-vm",
      "restore_from": "repository",
      "overwrite_existing": false,
      "database_mappings": [
        { "source_database": "APPDB", "target_database": "APPDB_DRILL" }
      ]
    }
  ]
}

An excerpt of the backup_restore block in data/restore_config.json: the fields this flow uses. The rest of each entry is left out.

  • A backup job names its databases as a list, or an empty list with "all_databases": true.
  • offload_* on a backup entry: the repository by server_id and folder, the copy retries, whether the copy is encrypted there and for how many days a key encrypts, and whether the source may be deleted once the copy is verified.
  • A Windows source is read over SMB (offload_source_share, offload_source_username and offload_source_password_ref, the three together) or over the SSH it already answers (offload_transfer: "sftp").
  • A restore entry states restore_from ("server" or "repository") and overwrite_existing (true or false). false never replaces a database that exists on the target.
  • An Oracle backup entry states oracle_sid and record_chain. A restore entry states server_metadata.enabled, and when it is on, where the instance's metadata comes from: source "node", "server" or "repository", with its path; a backup entry's repository_path is where its offload carries the sealed metadata.
  • A script-driven SQL Server restore names its databases: database_mappings (source_database to target_database; another name restores it beside what the target holds) or "restore_all_databases": true, one of the two.
Architecture

16 components

Eleven apps, each doing one job with its own CLI and never importing another app, and five shared layers that every app stands on. The list is closed, and every component has exactly one reference doc.

Who may call whom

Scroll sideways to see the whole diagram.
11 apps jobs · metrics · sql_tasks · reports · telegram backup_restore · sla · sre · control · webhost · mcp import transportthe one client dbruntime store logging_opslogs, job_runs commonoperations, CLI only starts common.cli lib pure rules: imported everywhere, runs nothing
  • common may not be imported: it is only ever run as a CLI.
  • lib may not run a CLI: it is only ever imported.
  • No app imports another app. No shared layer imports an app.
  • Each rule has a guard test beside it, so the diagram describes what is true, not just what was intended.

Apps

03App command daemon

dbabrain/jobs · dbabrain daemon

The scheduler: runs each app on its own interval inside its allowed hours, skips one that is still running.

04Metrics engine

dbabrain/metrics

Around ninety metrics across the supported engines, collected and normalised into one shape.

05SQL task runner

dbabrain/sql_tasks

Your own SQL, on a schedule or on request, against approved targets, as text or a spreadsheet.

06Reports

dbabrain/reports

Scheduled reports and inventory pages, with a freshness gate against stale numbers.

07Chat delivery and commands

dbabrain/telegram

Delivers the outgoing queue and executes commands, gated by the person's and the chat's clearance.

08Backup / restore

dbabrain/backup_restore

Runs backups, restores them onto a disposable target, verifies, and records what was proven.

09SLA / SLO compliance

dbabrain/sla

Indicators from stored measurement history, objectives with an error budget.

10SRE

dbabrain/sre

Provisions disposable lab databases for drills: single instances or small HA clusters, in Docker or on VMs.

11Control

dbabrain/control

Builds and deploys the toolkit to another node, and watches the toolkit itself.

12Web host

dbabrain/webhost

Serves the rendered reports over HTTP and hosts the console. Publishes files, never generates them.

16MCP server

dbabrain/mcp

Every common.cli command and the runtime store as MCP tools for Claude or any MCP client, each command's own gate kept, every answer redacted and capped.

Shared layers

01Runtime store

dbabrain/db

The toolkit's own data: job runs, measurements, report state, delivery queue, restore history. SQLite to start, PostgreSQL later.

02Logging engine

dbabrain/logging_ops

Scoped application logs, runtime logs, shared errors and daily archives.

13Common

dbabrain/common · CLI only

Reaching a host, running SQL, moving a file, rotating a password. Every command takes one JSON object.

14Lib

dbabrain/lib · import only

Pure rules: time windows, notify routing, severity, formatting. Imports nothing from the rest.

15Transport

dbabrain/transport

The one client: starts common.cli and db.cli for every component. Imports only lib.

So sánh

DBA Brain hay một thư mục script

Điều gì thay đổi khi các check, backup và report được chuyển ra khỏi hàng chục cron job và script ad-hoc, hoặc khỏi một agent tự viết raw SQL.

Bạn cần gìDBA BrainCron job và script ad-hoc
Ngưỡng và schedulemỗi quyết định nằm ở đâu Các file JSON bạn quản lý trong version control: một thay đổi là một diff và một lượt review Nằm trong từng script: một thay đổi là sửa script của ai đó
Một backup đáng tin cậylàm sao biết nó restore được Được restore lên một disposable target và verify: chính lần restore là bằng chứng Một file trên đĩa, trừ khi bạn tự xây và schedule restore drill của riêng mình
Bản ghi cho mọi lần chạyđêm qua đã chạy gì, và ai khởi chạy Một dòng trong job_runs và một dòng log cùng định dạng, bất kể ai khởi chạy Tuỳ mỗi script chọn ghi log gì
Một lần chạy thất bạichạy lại Chạy lại thủ công từ đúng JSON request đó Tuỳ từng script
Số liệu cũkhi việc thu thập dừng lại Freshness gate: một số liệu cũ không bao giờ được đưa vào report như số liệu hiện tại Tuỳ từng script
Mật khẩukhi lưu và khi truyền Mã hoá khi lưu (PBKDF2-HMAC-SHA256 + Fernet), truyền qua stdin, không bao giờ qua dòng lệnh Tuỳ mỗi script cất ở đâu
Một AI agent làm việc với databasenó được phép làm gì Chỉ những lệnh có sẵn, mỗi lệnh được review khi viết ra và được ghi log như một lần chạy của người SQL soạn từ prompt: phạm vi ảnh hưởng là bất cứ thứ gì nó tình cờ viết ra
Agent đọc những gìtoken cho mỗi lần kiểm tra Một verdict đã được grade, rồi chỉ bằng chứng cho những gì có vấn đề Mọi dòng của mọi lần kiểm tra, dù khoẻ hay không
Trên các máy được monitorcài những gì Không gì cả: một kết nối và một credential bạn đã có sẵn Cũng không gì cả

Mọi dòng ở phía DBA Brain đều lấy từ README của dự án.

Mã nguồn mở

Miễn phí. Tất cả.

DBA Brain miễn phí và mã nguồn mở theo Apache License 2.0: mã nguồn, tài liệu và mọi release trên PyPI.

Ủng hộ dự án

Hãy liên hệ

DBA Brain do một người duy trì. Mọi sự giúp đỡ dưới các hình thức sau đều được hoan nghênh.

  • Quyên góp để dự án tiếp tục được duy trì
  • Tài trợ cho dự án
  • Đầu tư hoặc hợp tác
  • Lập trình viên muốn cùng chúng tôi phát triển tiếp
  • Báo lỗi và đề xuất tính năng qua GitHub issues
Liên hệ
Cài đặt

Bắt đầu

Python 3.12+. Mỗi driver database là một extra, nên bạn chỉ cài những gì mình dùng. Được publish lên PyPI qua trusted publishing.

ExtraDùng cho
[postgres]PostgreSQL, pure Python
[mysql]MySQL / MariaDB, pure Python
[oracle]Oracle, không cần thư viện client cho 12.1 trở lên
[mssql]SQL Server, cần thêm ODBC driver của Microsoft
[ssh], [winrm]Metric cấp OS trên host Linux / Windows
[ai]trợ lý AI (tuỳ chọn)
[mcp]MCP server, cho Claude hoặc mọi MCP client
[all]tất cả

Cài đặt

shell
python -m venv .venv
.venv/bin/pip install 'dbabrain[postgres,ai]'
dbabrain init                   # in an empty folder: the tool root
dbabrain key-request            # free, 14 days; reports, backup / restore and the AI need it

Metric và alert chạy không cần key; key mở khoá những gì, và hiệu lực bao lâu (14 ngày, sau đó dbabrain key-renew).

Hoặc chạy từ container: mỗi release đều được publish dưới dạng ghcr.io/tanthanhkaka01/dbabrain:<version> - xem hướng dẫn cài đặt và hướng dẫn docker-node.

Dùng thử năm phút với một container PostgreSQL dùng xong bỏ

shell
cd examples/postgres-quickstart
docker compose up -d
dbabrain db      --config config.json init
dbabrain metrics --config config.json collect --dry-run
dbabrain metrics --config config.json collect
dbabrain metrics --config config.json report
Hỏi đáp

Câu hỏi thường gặp

DBA Brain có cài gì lên database của tôi không?

Không. Không agent, không extension, không stored procedure. DBA Brain tiếp cận database và host theo cách một người vận hành vẫn làm: qua một kết nối và một credential bạn đã có sẵn. Metric chỉ cần một login read-only để query; backup, restore và các lệnh làm thay đổi hệ thống dùng một login có đủ quyền cho các thao tác đó.

DBA Brain có chạy được khi không có internet không?

Một phần. Không có dbabrain key, DBA Brain vẫn thu thập và grade metric, chạy SQL theo schedule và các SLA check, và chạy console, hoàn toàn không cần internet. Report, backup / restore, các lệnh SRE, MCP server và trợ lý cần key, và key lấy từ dbabrain.dev: dbabrain key-request là một lần đăng nhập bằng email, hiệu lực 14 ngày, sau đó dbabrain key-renew. Bản thân key được kiểm tra ngay trên node, offline; lần check hằng ngày không tới được dbabrain.dev cũng không làm thay đổi gì. Key xin trên một máy có internet có thể được chép vào store của node bằng dbabrain common secret-set - (ref DBABRAIN_KEY). Về bản chất, alert Telegram, trợ lý và connector claude.ai cần internet.

DBA Brain có gửi dữ liệu của tôi đi đâu không?

Không telemetry, không usage report, không update check. DBA Brain kết nối tới các database và host bạn liệt kê; nếu có dbabrain key, mỗi ngày một lần tới dbabrain.dev để kiểm tra key đó; và chỉ khi bạn bật từng thứ, tới một dịch vụ chat và tới AI (qua dbabrain.dev, hoặc API của một model bằng key của riêng bạn). Ngoài ra không gì khác. Lần check hằng ngày chỉ gửi key - không gửi gì về database của bạn. Dù model tiếp cận hệ thống của bạn theo cách nào, kết nối đều được mở từ máy của bạn ra ngoài: không public IP, không inbound port, không server (cách một model tiếp cận hệ thống của bạn).

DBA Brain làm việc với những database nào?

SQL Server, Oracle, PostgreSQL và MySQL / MariaDB, mỗi engine qua pip extra riêng, cộng thêm metric cấp OS trên host Linux và Windows qua SSH hoặc WinRM. Khoảng chín mươi metric trên các engine được hỗ trợ.

DBA Brain có đang chạy production không?

Có. Các chức năng chính đã ổn định và đang chạy production - trên một hệ thống có nhiều instance SQL Server, cùng vài instance Oracle và PostgreSQL với workload vừa phải. MySQL và workload nặng hơn đều được hỗ trợ, nhưng đến nay ít thời gian chạy production hơn.

DBA Brain có phải là AI agent không? Tôi có cần một AI agent không?

DBA Brain là harness để một model AI làm việc qua đó: tốt hơn khi có AI, vẫn đầy đủ khi không có. Scheduler, việc grade, backup và alert là code và SQL đã review; không phần nào cần đến model, và dù có AI hay không, mọi lần thu thập, backup, report và alert đều chạy y như nhau.

Trợ lý tích hợp sẵn (tuỳ chọn) hỗ trợ hằng ngày cho DBA và DevOps engineer: trợ lý tự đọc alert, backup, job, query chậm, plan regression và index, giải thích chúng, và đưa ra đúng lệnh cho bước tiếp theo (tên khi release là Phanes; mỗi bản cài có thể đổi tên bằng assistant_name trong ai_assist.json). Trợ lý trả lời khi node của bạn có dbabrain key miễn phí (dbabrain key-request, đăng nhập bằng email trên dbabrain.dev) - qua dbabrain.dev, không cần Anthropic key của bạn - đọc qua các tool read-only, và đề xuất lệnh để một người chạy. Trên một bản cài mới, key là bước đầu tiên sau dbabrain init và passphrase; dbabrain ai-key thì dùng Anthropic key của riêng bạn. Sau đó hỏi trợ lý trong terminal (dbabrain telegram ai-ask "What do I set up next?") hoặc trong Telegram. Một AI client cũng có thể điều khiển dbabrain trực tiếp qua MCP (dbabrain mcp serve).

Có web console không?

Web host phục vụ các report và một console để sửa config. Chưa có chức năng thêm instance từ trình duyệt (host, port, user, password): cách được hỗ trợ là viết các file JSON, bằng tay hoặc nhờ một agent; hướng dẫn chạy lần đầu đi qua từng bước.

DBA Brain lưu dữ liệu của chính nó ở đâu?

Trong runtime store: các lần chạy job, phép đo, trạng thái report, hàng đợi gửi tin và lịch sử restore. Bắt đầu với SQLite, chuyển sang PostgreSQL khi hệ thống lớn hơn; backend chỉ là một từ trong một file.

Mật khẩu được lưu thế nào?

Được mã hoá: PBKDF2-HMAC-SHA256 với salt riêng cho từng file, seal bằng Fernet. Passphrase được cung cấp lúc chạy và không bao giờ được ghi ra đĩa, log hay store. Một request mang mật khẩu đi qua stdin, không bao giờ qua dòng lệnh. Config chỉ ghi tên một reference, được resolve từ biến môi trường trước, nên một secret manager bên ngoài cũng dùng được. Không secret nào đi vào qua MCP: request mang mật khẩu, key hoặc token sẽ bị từ chối, và model gọi một secret bằng reference của nó.

DBA Brain dành cho ai?

Một DBA hoặc một team nhỏ quản lý từ vài đến vài chục instance trên nhiều hơn một engine; người phụ trách DevOps hoặc SRE bị page khi database có sự cố dù không phải là DBA; và bất kỳ ai xây một agent cần đụng tới database mà không muốn giao cho nó một shell. Nếu bạn chỉ có một cluster PostgreSQL và đã hài lòng với một sản phẩm monitoring dạng hosted, thì DBA Brain cồng kềnh hơn mức bạn cần.

DBA Brain tốn bao nhiêu tiền?

Công cụ: không tốn gì. Cài đặt và sử dụng miễn phí, mã nguồn mở theo Apache License 2.0. Nếu bạn cần chúng tôi làm các công việc DBA - migrate sang engine khác, setup backup và restore, tuning, setup DBA Brain trên server của bạn - hãy liên hệ: chúng tôi làm gì. DBA Brain do một người duy trì; nếu bạn muốn quyên góp, tài trợ hoặc đầu tư, hãy xem trang liên hệ.

Năm phút

Một container dùng xong bỏ, bảy phép đo thật

Bản quickstart PostgreSQL không cần cài package hệ thống nào: một container, một login quyền tối thiểu, bảy phép đo thật, và không có gì phải gỡ cài đặt sau đó.