Skip to content
DBA Brain
SQL Server restore, a real run

SQL Server restore from an encrypted backup repository, step by step

This is one restore that DBA Brain ran on 2026-11-28, written down end to end: what had to be in place, how the backup files were kept and recorded, the command, how the files were chosen, every Telegram message, what was checked before it said done, and the same result checked again by hand through MCP. Every figure below was read from the run - its store rows, its log, its messages. Only the names are changed.

The whole run was one command

Everything on this page - 155 files found on the repository, decrypted and proven, five chains checked by LSN, 155 RESTORE statements, DBCC CHECKDB, the cleanup and 175 Telegram messages - dbabrain did on its own, after one command. Either of these starts it:

one command
# in Telegram, to the dbabrain bot
/spbot_restore ACME_SQL_PROD_TO_LAB_DOCKER

# or on the dbabrain node
dbabrain backup_restore restore-by-id '{"restore_id": "ACME_SQL_PROD_TO_LAB_DOCKER"}'

The entry it names is written once (section 2) and runs again with the same command, or by itself on a schedule. The sections below are not steps to follow: they are what that one command did, and how it can be checked - through MCP, two read-only calls (section 8).

Why this one command is not an MCP tool. A restore is an operation to weigh carefully and to set up carefully: which backups, onto which server, under which names, what may never be overwritten, how much room it needs. That is decided once, by a person, in the entry - and the run is started by a person, from Telegram or the command line. On purpose, an AI agent through MCP does not start a whole restore: it reads, checks and verifies.

1. What ran

Restore entryACME_SQL_PROD_TO_LAB_DOCKER - on demand only (active: false)
SourceACME-SQL-PROD-01, SQL Server 2022 (16.00.4305), production. Not touched by the restore: every file came from the repository
RepositoryACME-BACKUP-REPO, a Linux host reached over SSH: /srv/backup-repo/ACME-SQL-PROD-01/<DB>/FULL|DIFF|LOG/, every file sealed with age (X25519)
TargetACME-LAB-MSSQL22, SQL Server 2022 Developer in Docker (mssql22_restore) on a lab VM (Ubuntu 24.04, 2 vCPU, 10 GB RAM)
Run bythe dbabrain node, dbabrain 1.3.0
Askedthe newest backup (no point_in_time)
Databases5: SALES_DB, APP_DB, APP_STG, ARCHIVE_DB, PORTAL_DB
Chain, each databaseFULL *_FULL_20261122_180029Z.bak + DIFF *_DIFF_20261127_200028Z.bak + 29 logs (*_LOG_20261127_201151Z.trn ... *_LOG_20261128_030110Z.trn) - 31 of the 1,397 files the repository holds for that database
Moved155 files, 70,492,491,776 bytes (65.7 GiB), decrypted on the way, every one matched by bytes and SHA-256, none copied twice
Result5 of 5 restored, ONLINE, to the end of their chains; CHECKDB 5 checked, 0 unusable; 155 of 155 staged plain copies deleted
Time03:03:58Z - 05:05:01Z: 7,262 s (2 h 01 min)
Telegram175 messages to the restore chat (plus 2 for the dry run before it)
Checked by handthrough MCP afterwards: the last LSN restored on the target equals the source's last log backup LSN, for all five databases (section 8)

The path every file took:

the path
 ACME-SQL-PROD-01            ACME-BACKUP-REPO                 dbabrain node                ACME-LAB-MSSQL22 (Docker)
 (SQL Server 2022)           (Linux, SSH)                     (worker)                     (SQL Server 2022, lab VM)
 ─────────────────           ──────────────────────           ─────────────────            ─────────────────────────
 BACKUP FULL/DIFF/LOG  ──►   copy, SHA-256 = source  ──┐
  sha256 on the server        age-encrypt, prove      │
  catalog row (store)         source file deleted     │
                                                      │   restore-by-id:
                              FULL.bak.age  ──────────┼──► stream .age, decrypt  ───►   /restore/<entry>/<DB>/FULL/...
                              DIFF.bak.age            │    in memory, prove bytes      bytes + SHA-256 proven,
                              29 x LOG.trn.age        │    + SHA-256 before naming     RESTORE HEADERONLY -> LSN chain
                                                      │                                RESTORE FULL/DIFF/LOG ... RECOVERY
                                                      │                                DBCC CHECKDB
                                                      └────────────────────────────►   plain copies deleted (proven)

The source server is not contacted for a file: the catalog says which repository copy is proven, and the restore reads only that.

2. Before it can run - the preconditions

Each item: what provides it, and what happens without it - in the tool's own words.

On the node

PreconditionProvided byWithout it
The secret store opens - the target's SA password, the SSH logins and the age key are in itDBABRAIN_SECRET_KEY; on a worker, worker-run hands it to the one command on stdinNo decryption key provided. Pass --key or set the DBABRAIN_SECRET_KEY environment variable.
A dbabrain key whose plan includes backup and restoredbabrain key-requestthe scheduled backup / restore workflow does not start; a restore asked for by hand still runs and says CRITICAL that the key is missing or ended. A key whose plan lacks the feature: backups and restores are not in this key's plan (...)
The runtime store reachable - the backup catalog lives theredata/store_config.jsonrestore_from repository reads the backup catalog - where each copy is and what it was proven as - and no catalog is open.

In the inventory (data/db_instances.json) and the logins

RecordWhyWithout it
Source ACME-SQL-PROD-01 with cmd_access enabledlooked up even though no file is read from it - the restore proves the target is not the sourceserver_id not found in db_instances.json / cmd_access is not enabled for ...
Target ACME-LAB-MSSQL22: db_type sqlserver, port 1433, container_name mssql22_restore, environment lab, cmd_access (SSH to the VM)the SQL port, the container, the SSH login for stagingno port: the target's SQL Server port is not stated ...; a production or unknown environment is refused unless allow_production_target: true; target = source: Refused: a restore there would overwrite production with its own backup.
Repository host ACME-BACKUP-REPO with an SSH cmd_accessread from the catalog, not from the backup entry: the server holding the files' verified copiesno verified repository copy of {dir} - offload the backups first, or state restore_from: server.
Target SQL login: env.MSSQL_USER (sa) stated, its password a secret ref in env_secrets.MSSQL_PASSWORDthe RESTORE and CHECKDB connectionenv.MSSQL_USER is not stated - the restore would log in as sa; state it ...; a ref not in the store: ... which is not in the secret store.

The backup entry - what made the files

ACME_SQL_PROD_FULL (and _DIFF, _LOG): a weekly FULL, a daily DIFF, a LOG every 15 minutes, five databases, and the offload block that puts every file on the repository:

restore_config.json - backups[]
"offload_enabled": true,
"offload_server_id": "ACME-BACKUP-REPO",
"offload_folder": "/srv/backup-repo",
"offload_encrypt": true,
"offload_encrypt_key_days": 90,
"offload_transfer": "sftp",
"offload_delete_source": true,
"offload_repository_check": true,
"offload_retention": {"FULL": 5184000, "DIFF": 2592000, "LOG": 1209600},
"offload_files_since": "2026-11-11T04:16:00Z",
"scrub_files_per_run": 20

The restore reads one field of it: offload_transfer - how a .age travels from the repository. With no backup entry offloading that server: no backup entry of {server} offloads to a repository - its offload_transfer says how a repository copy travels.

The restore entry - every field this run read

restore_config.json - restores[]
{
  "restore_id": "ACME_SQL_PROD_TO_LAB_DOCKER",
  "active": false,
  "db_type": "sqlserver",
  "server_id": "ACME-SQL-PROD-01",
  "target_server_id": "ACME-LAB-MSSQL22",
  "target_container": "mssql22_restore",
  "backup_dir": "D:\\SQLBACKUP",
  "source_backup_host_dir": "D:\\SQLBACKUP",
  "target_backup_dir": "/srv/dbabrain/restore/ACME_SQL_PROD_TO_LAB_DOCKER",
  "target_visible_dir": "/srv/dbabrain/restore/ACME_SQL_PROD_TO_LAB_DOCKER",
  "script": "assets/restore/sqlserver/mssql_restore.sh",
  "env": {"MSSQL_USER": "sa", "BACKUP_CERT_NAME": "backup_cert"},
  "env_secrets": {"MSSQL_PASSWORD": "TARGET_SA_PASSWORD"},
  "overwrite_existing": false,
  "cleanup_retention": 86400,
  "time_window": {"from_hour": 0, "to_hour": 23, "repeat_interval": 604800, "retry_interval": 3600, "timeout": 43200},
  "notify": {"logging_on_run": {"enabled": true, "telegram_chat": "restore", "chat_id": ""},
             "alert_on_error": {"enabled": true, "telegram_chat": "restore", "chat_id": ""}},
  "server_metadata": {"enabled": false, "artifacts": [], "phases": []},
  "action": "restore",
  "restore_from": "repository",
  "integrity": {"algorithm": "sha256", "copy_max_retry": 3, "copy_retry_interval_seconds": 30,
                "verify_source_before_copy": true, "uncatalogued": "refuse", "engine_verify_before_restore": false},
  "staging_marker": ".dbabrain-staging",
  "database_mappings": [
    {"source_database": "SALES_DB", "target_database": "SALES_DB"},
    {"source_database": "APP_DB", "target_database": "APP_DB"},
    {"source_database": "APP_STG", "target_database": "APP_STG"},
    {"source_database": "ARCHIVE_DB", "target_database": "ARCHIVE_DB"},
    {"source_database": "PORTAL_DB", "target_database": "PORTAL_DB"}
  ],
  "allow_production_target": false,
  "checkdb": true,
  "copy_selection": "chain",
  "space_check": {"enabled": true, "factor": 2.0, "on_unknown": "refuse"},
  "checkdb_timeout_seconds": 14400,
  "checkdb_jobs": 1,
  "tier": null,
  "copy_mode": "auto"
}
FieldWhat it decided in this run
restore_from: repositoryfiles come from the repository's proven copies, never from the source server
copy_selection: chainonly the chain is moved - 31 of 1,397 files per database
database_mappingswhich databases, and the name each lands under
overwrite_existing: falsea landing name the target already holds stops the run before anything is copied
allow_production_target: falsethe target's inventory environment must be non-production (lab here)
space_checkfree space on the target ≥ bytes to stage × 2
integritySHA-256, and how a copy that arrives different is handled
checkdb: trueDBCC CHECKDB on every restored database before done (section 7)
staging_markerthe staging folder is marked; nothing is ever deleted in a folder without the marker
notifyboth the run's messages and its alerts go to the restore chat (section 6)
cleanup_retention: 86400staged copies kept at most a day (here deleted at once, after the verified restore)
active: false, time_windownever scheduled; run by hand. A hand restore-by-id checks neither

Every one of these is required and stated: an entry missing one is refused with {label} states no {fields}, so a default nobody can read in the entry would decide: ... State it/them, or run upgrade-config.

The files, the target and the room

PreconditionThis run
Every chain file is a proven encrypted copy (repository_encrypted_files)155 of 155. A file no offload recorded: on the repository, N file(s) of the chain are not proven encrypted copies - ... - nothing is restored from a file no offload recorded.
The age key opens: its private half is in the store, sealed with the passphrasekey id 12; otherwise repository key {id} cannot be decrypted. The private half is never on the repository
A certificate - only when the backup was certificate-encryptednot needed: 4. Certificate: none - none needed - the backup is not encrypted. When needed it comes from dbabrain's vault only, never from beside the backups
The staging folder: at least three levels deep, not shared with another entry, visible to the container at the same path/srv/dbabrain/restore/<restore_id>, bind-mounted into mssql22_restore
Room for the staged files: free ≥ bytes to stage × factorspace check: 65.7 GiB to copy, x2 = 131.3 GiB needed, 439.1 GiB free - fits, measured with df on the target
Room for the restored databases - the DBA's own sizing, not measured by dbabrainmeasured by hand before the run: SALES_DB allocates 199.00 GB data + 35.45 GB log on the source (sys.master_files), the five 238 GB; the VM had 43 GB free on 140 GB, so its disk was grown to 560 GB first
No landing name on the target (with overwrite_existing: false)none of the five existed; checked read-only by the dry run before anything moved

The dry run - read the plan, change nothing

shell
dbabrain backup_restore restore-by-id '{"restore_id": "ACME_SQL_PROD_TO_LAB_DOCKER", "dry_run": true}'
answer
APP_DB: FULL 1 + DIFF 1 + LOG 29 of 1397 file(s) on the source
APP_STG: FULL 1 + DIFF 1 + LOG 29 of 1397 file(s) on the source
ARCHIVE_DB: FULL 1 + DIFF 1 + LOG 29 of 1397 file(s) on the source
PORTAL_DB: FULL 1 + DIFF 1 + LOG 29 of 1397 file(s) on the source
SALES_DB: FULL 1 + DIFF 1 + LOG 29 of 1397 file(s) on the source
{"success": true, "operation": "restore-by-id", "message": "ACME_SQL_PROD_TO_LAB_DOCKER dry run: the plan was read, nothing restored (sqlserver).", ...}

The dry run reads the chain where the copy would, asks the target (read only) whether each landing name exists, and answers the transfer plan, the space check, what it would refuse and the steps. It sends two messages (start, end) and restores nothing.

3. How dbabrain keeps the files - and records them

One file's life: SALES_DB_FULL_20261122_180029Z.bak

When (UTC)WhatRecorded
2026-11-22 18:00:30 - 18:31:37the backup job runs BACKUP DATABASE on the source; the file is hashed on the serverbackup_files row 59805: size_bytes 53733711872, checksum_after_backup 3c8d5252...15830341, engine_verify passed, verdict ok, offload_state pending
2026-11-22 18:39:34re-checked on the sourcelast_check_result match, the same hash
2026-11-22 19:40:30offloaded: streamed to the repository over SSH and landed only as ...bak.age; the .age read back, decrypted and held to the plain bytes and SHA-256offload_state verified; repository_encrypted_files row 35747: plain_size_bytes 53733711872, plain_sha256 3c8d5252..., encrypted_size_bytes 53746830810, encrypted_sha256 87ee4909...b3b0bb2c9, age-x25519, key_id 12
2026-11-22 19:56:51released at the source: the repository copy proven again, then the source file deleted (name, path, size and SHA-256 must all match, one file per command)state pruned, source_deleted_at 19:56:51
2026-11-28 03:53:22 - 05:05:00used by this restorelast_restore_run_id 10060, last_restore_result done, last_restore_verdict match, last_restore_target_server_id ACME-LAB-MSSQL22

Every row carries a row_hash chained to the row before it, so an edited row shows.

The repository

  • Layout: <offload_folder>/<server_id>/<DB>/FULL|DIFF|LOG/<file>.age - here /srv/backup-repo/ACME-SQL-PROD-01/SALES_DB/FULL/SALES_DB_FULL_20261122_180029Z.bak.age.
  • Encryption: age (X25519). The node holds the private half sealed with the store's passphrase, and a sealed file for an offline recovery key; the repository holds only .age files and never a key. A key encrypts for offload_encrypt_key_days (90) and is never deleted - an expired key still decrypts.
  • Retention (offload_retention, seconds after the backup ended): FULL 60 days, DIFF 30, LOG 14; never the newest chain of a database; a FULL only when every DIFF and LOG depending on it is past retention too. Each expiry is one delete held to its bytes and SHA-256.
  • Folder check after each offload pass: the folder listed against what the catalog proved there; a stray file, a missing one or a size that differs fails the run. A check that finds files a sibling offload of the same server is still writing waits for the next pass.
  • Never on the repository: certificates and keys.

The tables a reader can query

Through the store-query and store-schema MCP tools:

TableOne row per
backup_runsbackup job run
backup_filesbackup file: hashes, chain parent, state, offload, last restore
repository_encrypted_filessealed copy: plain and encrypted bytes + SHA-256, key id
repository_keysage key generation (private half sealed)
restore_runsrestore run: phase, chain files, matched, databases ok / failed, where each landed
restore_run_filesfile staged for a restore: paths, sizes, SHA-256 before and after, verdict (155 rows here)
restore_chain_filesfile in the restore plan: step, position, landing name, with recovery, STOPAT, result (155 rows)
telegram_send_messagesmessage sent (175 rows)

4. The command

shell
dbabrain backup_restore restore-by-id '{"restore_id": "ACME_SQL_PROD_TO_LAB_DOCKER"}'
Field
restore_idrequired (restore_id is required.)
point_in_timeabsent = the newest backup; a moment as YYYY-MM-DD HH:MM:SS +HH:MM or ISO with an offset
dry_runtrue: read the plan, restore nothing

On a worker the passphrase is never on a command line or in Docker's configuration. This run was started with worker-run, which hands the passphrase to that one command on stdin, detached so it outlives the SSH session:

shell
dbabrain control worker-run --key-base64 <K> -- sh -c 'setsid nohup python -m dbabrain.backup_restore.cli restore-by-id
  '"'"'{"restore_id": "ACME_SQL_PROD_TO_LAB_DOCKER"}'"'"' > logs/restore.log 2>&1 < /dev/null &'

Other ways to run the same entry:

WayWhat it does
Telegram /spbot_restore_plan <restore_id> [moment]the dry run, 30 minutes at most
Telegram /spbot_restore <restore_id> [moment]the restore, in the background, active or not, with a claimed run row - the same code path
ScheduledAPP-BACKUP-RESTORE runs an entry that is active when its time_window is due. This entry is inactive: never scheduled
MCPrestore-by-id is not an MCP tool. The restore tool runs one engine step at a time - step: full, then diff, then log, then verify-restore

5. How the files are chosen

What travels - before anything is copied

The repository folder of each database is listed (no hashing) and the chain is cut from the file names' UTC stamps:

Newest backup (this run)A point in time
FULLthe newest FULLthe newest FULL at or before the moment
DIFFthe newest DIFF at or after that FULLthe newest DIFF at or after that FULL and at or before the moment
LOGevery LOG from the DIFF (or the FULL) onevery LOG from the DIFF on, up to and including the first LOG that reaches the moment

This run, per database: FULL 2026-11-22 18:00Z (the week's FULL), DIFF 2026-11-27 20:00Z (the newest of five DIFFs on that FULL), then the 29 logs from 20:11:51Z to 03:01:10Z the next morning - 31 of 1,397 files. The other 1,366 stay on the repository. No FULL before a moment: no FULL at or before the moment for X - the earliest point it can be restored to is after its oldest full (...).

How they travel

Each .age is streamed from the repository over SSH, decrypted in the node's process on the way - the key never written to disk, the plain file never on the node - and written to a partial name on the target. It takes its real name only when the .age matched its recorded bytes and SHA-256 and the plaintext matched the plain bytes and SHA-256; otherwise the partial is removed and the restore stops.

The plan on the target - LSNs

After the copy the staged files are read by the target instance: RESTORE HEADERONLY on each gives its type, database, finish date, FirstLSN, LastLSN, CheckpointLSN and DifferentialBaseLSN. Then, per database:

  • FULL = the newest (before the moment); DIFF = the newest finished after it; LOGs = all finished after the DIFF; for a moment, every log finished by then plus the first one after it (the one whose STOPAT lands inside).
  • The chain is proven before the first RESTORE: the DIFF's DifferentialBaseLSN = the FULL's CheckpointLSN; the first log ending after the DIFF starts at or before the DIFF's LastLSN; each log starts at the previous log's LastLSN. A gap: {id}: {db}: the backup chain is broken - a log backup is missing before X: it starts at LSN ..., the one before it ended at LSN .... Nothing was restored.
  • A point in time is converted to the source's clock first (the offset read from the log files' UTC name stamp against their header finish time).
  • A database with no log backups (SIMPLE recovery): FULL (+ DIFF) with RECOVERY, no STOPAT.
  • A moment after the newest log: restored to the chain's end, with the warning the moment X is at or after its newest log backup (finished Y) - restored to that log's end; what came after it is in no backup yet.

The statements

  • FULL onto another server: RESTORE FILELISTONLY, every file MOVEd to the instance's default data and log paths as <database>_<logical name>, then RESTORE DATABASE ... WITH MOVE ..., NORECOVERY, CHECKSUM, STATS = 10. Without overwrite_existing: true a guard in the same batch refuses a database that exists.
  • DIFF and each LOG: RESTORE DATABASE|LOG [db] FROM DISK = ... WITH NORECOVERY, CHECKSUM, STATS = 10; the last file WITH RECOVERY (and STOPAT = '...' for a moment).

Where it stopped

Read back from the target after the check (msdb.dbo.restorehistory + backupset.backup_finish_date) and compared with the plan: with no moment, restored to the end of its chain when the last backup applied ended at the chain's end; with a moment, stopped at the moment asked or NOT at the moment asked.

DatabaseStateChain ends (+07)Last backup appliedVerdict
SALES_DBONLINE2026-11-28 10:01:12logrestored to the end of its chain
APP_DBONLINE2026-11-28 10:01:13logrestored to the end of its chain
APP_STGONLINE2026-11-28 10:01:14logrestored to the end of its chain
ARCHIVE_DBONLINE2026-11-28 10:01:10logrestored to the end of its chain
PORTAL_DBONLINE2026-11-28 10:01:14logrestored to the end of its chain

6. What Telegram says

175 messages for the run (and 2 for the dry run before it), all to the restore chat, all sent. Each is LOGGING|<node>|<restore_id> · <step> followed by its lines; a line with ❌ or a FAILED title makes it an error and routes it by alert_on_error.

StepMessagesRule
1. Restore process started1per run
2. Copy2per run, started + done
3. Instance metadata before the restore1per run
4. Certificate1per run
5. Restore full10per database, started + done (5.1 ... 5.5)
6. Restore diff10per database with a DIFF, started + done (6.1 ... 6.5)
7. Restore log145one per log file, numbered across the run (7.1 ... 7.145 = 5 × 29)
8. Check2per run, started + done
9. Instance metadata after the restore1per run
10. Plain files cleared1per run
11. Restore process done1per run
Total175

One message per step, never grouped to save messages: a reader sees where a long run is, and a failure names its step.

The messages as sent, one of each kind (times UTC):

Telegram - restore chat
03:03:58  LOGGING|node-01|ACME_SQL_PROD_TO_LAB_DOCKER · 1. Restore process started
          ACME-SQL-PROD-01 -> ACME-LAB-MSSQL22 · from the repository · to the newest backup
          steps: 2 copy -> ACME-LAB-MSSQL22 (decrypted from the repository), 3 metadata before,
          4 certificate, 5 full, 6 diff, 7 log, 8 check, 9 metadata after, 10 plain files cleared, 11 done

03:03:59  ... · 2. Copy to ACME-LAB-MSSQL22 started
          from the repository: the encrypted copies of ACME-SQL-PROD-01, decrypted on the way

03:53:48  ... · 2. Copy to ACME-LAB-MSSQL22 done
          ✅ 155 file(s) · 65.7 GB · decrypted from the repository's encrypted copies · bytes + SHA-256 proven

03:53:49  ... · 3. Instance metadata before the restore: not restored
          - server_metadata is off for this entry

03:53:49  ... · 4. Certificate: none
          - none needed - the backup is not encrypted

03:54:27  ... · 5.1 Restore full SALES_DB started
          SALES_DB: SALES_DB_FULL_20261122_180029Z.bak (backup finished 2026-11-23 01:20:18) - left restoring for the next step

04:12:29  ... · 5.1 Restore full SALES_DB done
          ✅ SALES_DB: SALES_DB_FULL_20261122_180029Z.bak (backup finished 2026-11-23 01:20:18) - left restoring for the next step · 1081 s

04:12:29  ... · 6.1 Restore diff SALES_DB started
          SALES_DB: SALES_DB_DIFF_20261127_200028Z.bak (backup finished 2026-11-28 03:06:18) - left restoring for the next step

04:22:36  ... · 6.1 Restore diff SALES_DB done
          ✅ SALES_DB: SALES_DB_DIFF_20261127_200028Z.bak (backup finished 2026-11-28 03:06:18) - left restoring for the next step · 606 s

04:22:38  ... · 7.1 Restore log SALES_DB_LOG_20261127_201151Z.trn done
          ✅ SALES_DB: SALES_DB_LOG_20261127_201151Z.trn (backup finished 2026-11-28 03:11:52) - left restoring for the next step (1 of 29 logs) · 1 s

   ...    7.2 ... 7.29 for SALES_DB; then 5.2 / 6.2 / 7.30-7.58 APP_DB, 5.3 / 6.3 / 7.59-7.87 APP_STG,
          5.4 / 6.4 / 7.88-7.116 ARCHIVE_DB, 5.5 / 6.5 / 7.117-7.145 PORTAL_DB

04:37:03  ... · 8. Check started
          each restored database: can it be opened, is it consistent

04:59:54  ... · 8. Check done
          ✅ 5 database(s) checked, 0 unusable

04:59:54  ... · 9. Instance metadata after the restore: not restored
          - server_metadata is off for this entry

05:05:00  ... · 10. Plain files cleared
          ✅ 155 of 155 plain file(s) deleted on ACME-LAB-MSSQL22 (65.7 GB)
          - staged backups past retention: 0 removed

05:05:01  ... · 11. Restore process done
          ✅ restored: SALES_DB: full SALES_DB_FULL_20261122_180029Z.bak + diff SALES_DB_DIFF_20261127_200028Z.bak + 29 log(s);
             APP_DB: full ... + diff ... + 29 log(s); APP_STG: ...; ARCHIVE_DB: ...; PORTAL_DB: ...
          ✅ checked: 5 database(s) checked, 0 unusable
          ✅ stopped: SALES_DB: last backup applied ended 2026-11-28 10:01:12 (restored to the end of its chain);
             APP_DB: ... 10:01:13 (...); APP_STG: ... 10:01:14 (...); ARCHIVE_DB: ... 10:01:10 (...); PORTAL_DB: ... 10:01:14 (...)
          ✅ plain files deleted: 155 of 155 staged copy(ies) (65.7 GB)
          7262 s

Backup finished is the source's clock (+07); sizes are 1024-based (the messages' "65.7 GB" is the space check's "65.7 GiB"); the elapsed seconds start after step 1. A step that does not apply is still said, as none with its reason. A failure ends with 11. Restore process FAILED at step N and ❌ <error>.

7. What is checked before "done"

CheckWhenThis run
Every chain file is a proven encrypted copybefore the copy155 / 155
The landing names are free on the target (overwrite_existing: false)before the copy5 free
Room for the staged files (space check)before the first file65.7 GiB × 2 = 131.3 GiB ≤ 439.1 GiB
Each file: the .age = its recorded bytes + SHA-256, and the plaintext = the plain bytes + SHA-256 (itself proven at the offload against the hash taken on the source server) - before the file takes its nameduring the copy155 match, 0 copied again
The LSN chain (DIFF base = FULL checkpoint; each log starts where the one before ended)before the first RESTORE5 chains unbroken
Each RESTORE's own result; SQL Server's CHECKSUM on every statementeach step155 applied
Each database ONLINE and openable (SELECT COUNT(*) FROM [db].sys.tables), then DBCC CHECKDB([db]) WITH NO_INFOMSGS; unusable = not ONLINE, absent or a CHECKDB errorstep 85 checked, 0 unusable (04:37:03 - 04:59:54)
Where each stopped, read from the target's restorehistory against the planafter step 85 × restored to the end of its chain
The staged plain copies deleted, each held to its bytes and SHA-256, fenced under the staging folderstep 10155 of 155 (65.7 GB)
The run's rows closedstep 11restore_runs 10060: phase done, chain_files 155, files_matched 155, files_recopied 0, databases_ok 5, databases_failed 0; each file's last_restore_*

What turns it into an error instead: any refusal before the copy, a file not proven, space short or unknown, a broken chain, a RESTORE error ({id}: step {k} of {n} failed - ...), a database unusable (restored, but verification failed - N of M database(s) unusable.) or not where it was asked (restored and checked, but not to what was asked - ...). The metadata steps and the cleanup never fail a verified restore - their problems are warnings.

8. Checked again by hand, through MCP

After the run, with dbabrain's own MCP tools, read only: first on the node (dbabrain mcp call <tool>), then from claude.ai through the DBA Brain connector.

list-objects on the target

request
{"kind": "databases", "server_id": "ACME-LAB-MSSQL22"}

The five databases of this run among the target's, each ONLINE, FULL recovery, compatibility 160.

run-sql on the target, master - state, CHECKDB, size

namestaterecoverycompatcreated (UTC)last good CHECKDB (UTC)data GBlog GB
APP_DBONLINEFULL16004:34:5304:37:041.630.13
APP_STGONLINEFULL16004:35:3504:37:100.070.07
ARCHIVE_DBONLINEFULL16004:36:0404:37:110.070.07
SALES_DBONLINEFULL16003:54:2704:37:11199.0035.45
PORTAL_DBONLINEFULL16004:36:3404:59:510.500.25

DATABASEPROPERTYEX(name, 'LastGoodCheckDbTime'): every database has a clean CHECKDB from step 8. The sizes equal the source's allocation.

run-sql on the target and on the source, msdb - the LSN proof

Asked from claude.ai through the DBA Brain connector: the restore history on the target, and the last log backup on the source.

dbrestores (target)last LSN restored (target)last log backup LSN (source)state
APP_DB31893000008348800001893000008348800001ONLINE
APP_STG31144000000404800001144000000404800001ONLINE
ARCHIVE_DB31138000009569600001138000009569600001ONLINE
SALES_DB31257060000010030400001257060000010030400001ONLINE
PORTAL_DB314700000557360000147000005573600001ONLINE

31 restores per database (1 FULL + 1 DIFF + 29 logs), and the last LSN restored on the target equals the source's last log backup LSN for all five: each copy is exactly the source as of 10:01 +07 - the end of the chain, nothing missing, nothing extra. Both calls answered committed: false, affected_rows: 0: run-sql checks for one SELECT and rolls back.

run-sql on the target, SALES_DB - the five largest tables

tablerowsreserved GB
dbo.order_line1,567,56136.44
dbo.shift_calc34,048,77213.88
dbo.event_log28,384,71911.50
dbo.shift_calc_detail29,377,44411.02
dbo.shift_result16,484,8588.24

store-query - the run's row

answer
{"columns": ["restore_run_id", "phase", "point_in_time", "chain_files", "files_matched", "files_recopied",
             "databases_ok", "databases_failed", "started_at", "ended_at"],
 "rows": [[10060, "done", "LATEST", 155, 155, 0, 5, 0, "2026-11-28T03:53:22Z", "2026-11-28T05:05:00Z"]]}

started_at is when the run row was written, at the end of the copy; the copy itself began at 03:03:59.

9. Times

StepFrom - to (UTC)TookSizeRate
Dry run (before)03:03:04 - 03:03:117 s--
2 copy: stream + decrypt + prove, 155 files03:03:59 - 03:53:4849 min 49 s65.65 GiB23.6 MB/s
3, 4 metadata, certificate03:53:490 s--
5.1 FULL SALES_DB03:54:27 - 04:12:291,081 s50.04 GiB49.7 MB/s
6.1 DIFF SALES_DB04:12:29 - 04:22:36606 s6.45 GiB11.4 MB/s
7.1-7.29 logs SALES_DB04:22:38 - 04:34:5212 min 14 s8.86 GiB13.0 MB/s
APP_DB, APP_STG, ARCHIVE_DB, PORTAL_DB (full + diff + 29 logs each)04:34:53 - 04:37:022 min 9 s0.30 GiB-
8 check (CHECKDB; SALES_DB 04:37:11 - ~04:59:51)04:37:03 - 04:59:5422 min 51 s199 GB data-
9 metadata after04:59:540 s--
10 plain files cleared (each hashed again before deletion)04:59:54 - 05:05:005 min 6 s65.7 GB-
Total03:03:58 - 05:05:017,262 s (2 h 01 min)

An earlier estimate for a whole day of this server's logs was 4 h 15 - 4 h 51 min. This chain carried 6.5 GiB of DIFF and 8.9 GiB of logs: the DIFF of the night before keeps the log part short. The copy (about 24 MB/s, decrypting in the node's process) and the CHECKDB of the 199 GB database are the two long steps.

10. Questions asked first

Does it touch the production server?

No. The files come from the repository's proven copies; the source is only looked up in the inventory, to refuse a restore onto itself.

Can it overwrite a database?

Not with overwrite_existing: false: a name the target holds stops the run before anything is copied.

What if a log is missing?

The chain is proven by LSN before the first RESTORE; a gap stops the run and names the file before which a log is missing.

How much disk does the target need?

Twice the staged backups for the copy (checked), and the databases' allocated size, not their backup size - the DBA's own sizing; dbabrain checks the copy only. Here 65.7 GiB of backups became 238 GB of database files.

Where does the key live?

In the node's store, sealed with its passphrase, plus an offline recovery copy. Never on the repository, never on the target.

How do I restore to a moment?

"point_in_time": "2026-11-28 08:30:00 +07:00" - the same chain cut at the first log reaching the moment, the last log WITH STOPAT; the verdict says stopped at the moment asked.

What stays behind?

The restored databases. The staged backups are deleted once the restore is verified.

How every backup is held to these checks: SQL Server backup verification. The fields above in full: the backup and restore reference. Everything else: DBA Brain.