@farhan0431/db-snap 0.3.14 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -2
- package/binaries/aarch64-apple-darwin/dbsnap +0 -0
- package/binaries/aarch64-unknown-linux-gnu/dbsnap +0 -0
- package/binaries/x86_64-apple-darwin/dbsnap +0 -0
- package/binaries/x86_64-pc-windows-msvc/dbsnap.exe +0 -0
- package/binaries/x86_64-unknown-linux-gnu/dbsnap +0 -0
- package/binaries/x86_64-unknown-linux-musl/dbsnap +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,6 +19,10 @@ snapshot before another restore; see the recovery steps below.
|
|
|
19
19
|
|
|
20
20
|
Requires Node.js 16 or later.
|
|
21
21
|
|
|
22
|
+
The verify/doctor/recover/exec/live-diff/row-preview/sandbox additions described
|
|
23
|
+
below are in the current repository after v0.3.14; a new published binary is
|
|
24
|
+
required to use them. Check `dbsnap --help` for the commands in your installation.
|
|
25
|
+
|
|
22
26
|
```bash
|
|
23
27
|
npm install -g @farhan0431/db-snap
|
|
24
28
|
dbsnap --version
|
|
@@ -73,7 +77,7 @@ the following to your project's `.cursor/mcp.json`:
|
|
|
73
77
|
Restart your client and ask it to run `dbsnap_status` to confirm the database
|
|
74
78
|
before making changes. The server also exposes tools to create, list, restore,
|
|
75
79
|
and prune snapshots. It resolves the project from its working directory, so
|
|
76
|
-
start it in the project you want to protect. The
|
|
80
|
+
start it in the project you want to protect. The current source exposes ten tools:
|
|
77
81
|
|
|
78
82
|
| MCP tool | Purpose |
|
|
79
83
|
| --- | --- |
|
|
@@ -83,6 +87,14 @@ start it in the project you want to protect. The six tools are:
|
|
|
83
87
|
| `dbsnap_diff` | Compare supported snapshots using `from` and `to`. |
|
|
84
88
|
| `dbsnap_restore_snapshot` | Restore a selected `tag_or_id`, or the newest snapshot. |
|
|
85
89
|
| `dbsnap_prune` | Prune with a positive integer `keep`; pinned snapshots survive. |
|
|
90
|
+
| `dbsnap_verify` | Check snapshot hashes/sizes/chunks, or clone existence; no SQL replay. |
|
|
91
|
+
| `dbsnap_doctor` | Report connectivity, journals, pending GC and untracked files. |
|
|
92
|
+
| `dbsnap_diff_live` | Save and retain a live checkpoint, then compare it with `from`. |
|
|
93
|
+
| `dbsnap_diff_rows` | Bounded SQLite primary-key row-change counts using `from`, `to`, and `table`. |
|
|
94
|
+
|
|
95
|
+
Results include text plus structured `ok`, `message`, optional typed `data` and
|
|
96
|
+
broad error codes. Snapshot creation returns the exact ID in data. Annotations
|
|
97
|
+
describe behavior but do not replace session permissions or elicitation.
|
|
86
98
|
|
|
87
99
|
Restore and prune are disabled by default in MCP. To enable them for a server
|
|
88
100
|
session, start it with `dbsnap mcp --allow-destructive`. Each operation requires
|
|
@@ -116,6 +128,15 @@ file; review it against the repository's current skill when upgrading.
|
|
|
116
128
|
| `dbsnap unpin <tag-or-id>` | Remove protection after reviewing the snapshot. |
|
|
117
129
|
| `dbsnap prune --all` | Delete all unpinned snapshots. |
|
|
118
130
|
| `dbsnap save tag --method dump` | Create a portable PostgreSQL dump snapshot. |
|
|
131
|
+
| `dbsnap verify [id-or-tag]` | Check one or all active snapshots; integrity/existence is not a restore test. |
|
|
132
|
+
| `dbsnap doctor` | Diagnose connection/recovery and report untracked files without deleting them. |
|
|
133
|
+
| `dbsnap recover` | Resume the recovery journal; ambiguous PostgreSQL states require inspection. |
|
|
134
|
+
| `dbsnap exec -- npm run db:migrate` | Checkpoint before a child command; retain it on failure, with no automatic rollback. |
|
|
135
|
+
| `dbsnap diff-live before` | Capture and retain the current state, then compare. |
|
|
136
|
+
| `dbsnap diff-rows before after --table users` | SQLite-only row-change counts by primary key, default limit 10,000 rows. |
|
|
137
|
+
| `dbsnap sandbox before --output experiment.db` | Fork SQLite into a new file; existing files are never overwritten. |
|
|
138
|
+
| `dbsnap sandbox before` | Create an independent PostgreSQL clone, recorded in `sandboxes.json`. |
|
|
139
|
+
| `dbsnap sandbox before --docker-image mysql:8.0` | Explicit isolated MySQL server; use `mariadb:11` for MariaDB. Docker required. |
|
|
119
140
|
|
|
120
141
|
`dbsnap list --json` and `dbsnap status --json` provide machine-readable output.
|
|
121
142
|
Pinned snapshots survive `prune`, including `--all`.
|
|
@@ -142,7 +163,47 @@ and row counts. It does not replay SQL into the target.
|
|
|
142
163
|
Equal row counts do not mean equal data. Individual row contents are not
|
|
143
164
|
compared. PostgreSQL diff excludes indexes, constraints, routines and triggers;
|
|
144
165
|
MySQL/MariaDB diff excludes views, routines, triggers and events. Unsupported
|
|
145
|
-
INSERT formats produce an error.
|
|
166
|
+
INSERT formats produce an error. Source additions after v0.3.14 compare two
|
|
167
|
+
PostgreSQL dump archives offline through `pg_restore`: archive-wide schema
|
|
168
|
+
changes and table counts from column-list COPY data, excluding ownership,
|
|
169
|
+
privileges, row contents and sequence values. Mixed clone/archive diff is
|
|
170
|
+
unsupported. The published v0.3.14 binary does not include archive diff.
|
|
171
|
+
|
|
172
|
+
`diff-rows` additionally supports SQLite added/removed/updated counts without
|
|
173
|
+
printing values. It requires explicit non-NULL primary keys and matching column
|
|
174
|
+
layouts, refusing previews above `--limit` (maximum 100,000). Server-engine row
|
|
175
|
+
diff is not implemented. `diff-live` uses storage and may briefly fence
|
|
176
|
+
PostgreSQL connections because it creates a regular retained snapshot.
|
|
177
|
+
|
|
178
|
+
## Checkpoints, diagnosis and sandbox experiments
|
|
179
|
+
|
|
180
|
+
`verify` and `doctor` print JSON. Verification failure exits nonzero. Doctor
|
|
181
|
+
reports a failed probe in its report and does not automatically repair anything.
|
|
182
|
+
`recover` reads the existing MySQL journal's ID or applies unambiguous PostgreSQL
|
|
183
|
+
journal recovery. It does not repair a stopped database server or choose an
|
|
184
|
+
arbitrary restore point. SQLite has no server recovery journal.
|
|
185
|
+
|
|
186
|
+
`exec` directly spawns a program without a shell, saving a checkpoint first.
|
|
187
|
+
Snapshot failure prevents execution. Child failure retains the checkpoint and
|
|
188
|
+
returns its ID, exit code and recovery command; the parent exits nonzero. Output
|
|
189
|
+
is returned up to 64 KiB per stream. `--db` selects the checkpoint database, not
|
|
190
|
+
the database your external program will use; set its environment deliberately.
|
|
191
|
+
Arbitrary command execution is CLI-only, not an MCP tool.
|
|
192
|
+
|
|
193
|
+
SQLite and PostgreSQL clone sandboxes let experiments target independent data.
|
|
194
|
+
Connect your migration/application explicitly to the returned file/database.
|
|
195
|
+
Cleanup is manual after closing sandbox connections. MySQL/MariaDB sandboxes
|
|
196
|
+
require explicit `--docker-image mysql:8.0` or `mariadb:11`: a separate Docker
|
|
197
|
+
server imports the verified dump with its original schema name, network disabled,
|
|
198
|
+
no published ports/host mounts/source credentials. Use `docker exec` for SQL
|
|
199
|
+
experiments and remove the returned container explicitly afterwards. Failed
|
|
200
|
+
imports remove only the newly created container. PostgreSQL dump sandbox and
|
|
201
|
+
same-server MySQL SQL rewriting are unsupported. See the workflow guide below.
|
|
202
|
+
|
|
203
|
+
Prune persists retired records in `metadata.json.pending_gc` and retries their
|
|
204
|
+
recorded artifact cleanup on a later prune. Shared survivor data and arbitrary
|
|
205
|
+
untracked files are preserved. Doctor reports pending GC and untracked staging.
|
|
206
|
+
Do not downgrade to an older binary unaware of `pending_gc` while it is nonempty.
|
|
146
207
|
|
|
147
208
|
## Recovering an interrupted MySQL/MariaDB restore
|
|
148
209
|
|
|
@@ -217,6 +278,7 @@ data you cannot afford to lose.
|
|
|
217
278
|
- [MCP installation guide](https://github.com/farhan0431/db-snap/blob/main/INSTALL.md)
|
|
218
279
|
- [Testing and audit coverage](https://github.com/farhan0431/db-snap/blob/main/docs/TESTING.md)
|
|
219
280
|
- [MySQL recovery](https://github.com/farhan0431/db-snap/blob/main/docs/MYSQL-RESTORE.md)
|
|
281
|
+
- [Development workflow and feature coverage](https://github.com/farhan0431/db-snap/blob/main/docs/DEVELOPMENT-WORKFLOW.md)
|
|
220
282
|
- [Report an issue](https://github.com/farhan0431/db-snap/issues)
|
|
221
283
|
|
|
222
284
|
MIT license.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|