@farhan0431/db-snap 0.3.8 → 0.3.10
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 +122 -0
- 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
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# dbsnap
|
|
2
|
+
|
|
3
|
+
**Database checkpoints for local development and AI coding agents.**
|
|
4
|
+
|
|
5
|
+
Save a snapshot before a migration or bulk edit, then restore the schema and
|
|
6
|
+
data if you need to roll back. Use dbsnap from your terminal or connect its
|
|
7
|
+
built-in MCP server to an AI assistant.
|
|
8
|
+
|
|
9
|
+
Supports **SQLite**, **PostgreSQL**, and **MySQL/MariaDB**. The npm package
|
|
10
|
+
bundles prebuilt binaries for Windows x64, macOS Intel and Apple Silicon, and
|
|
11
|
+
Linux x64 (glibc and musl) and ARM64 (glibc).
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Requires Node.js 16 or later.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g @farhan0431/db-snap
|
|
19
|
+
dbsnap --version
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or run without a global install:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npx -y @farhan0431/db-snap --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick start
|
|
29
|
+
|
|
30
|
+
Run these commands in the root of the project containing your development
|
|
31
|
+
database:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
dbsnap init
|
|
35
|
+
dbsnap status
|
|
36
|
+
dbsnap save "before migration"
|
|
37
|
+
|
|
38
|
+
# Run your migration or make changes here.
|
|
39
|
+
|
|
40
|
+
dbsnap list
|
|
41
|
+
dbsnap restore "before migration" # restores the selected snapshot
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`dbsnap init` detects `DATABASE_URL` or common SQLite paths. To choose a
|
|
45
|
+
database explicitly, use `dbsnap init --db ./prisma/dev.db`. Check the target
|
|
46
|
+
with `dbsnap status` before restoring: a restore changes the live database.
|
|
47
|
+
|
|
48
|
+
Snapshots and metadata live in `.dbsnap/` in your project. The directory is
|
|
49
|
+
added to `.gitignore` during initialization.
|
|
50
|
+
|
|
51
|
+
## Use with an AI assistant
|
|
52
|
+
|
|
53
|
+
Register dbsnap as an MCP server in a compatible client. For example, add
|
|
54
|
+
the following to your project's `.cursor/mcp.json`:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"mcpServers": {
|
|
59
|
+
"dbsnap": {
|
|
60
|
+
"command": "dbsnap",
|
|
61
|
+
"args": ["mcp"]
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Restart your client and ask it to run `dbsnap_status` to confirm the database
|
|
68
|
+
before making changes. The server also exposes tools to create, list, restore,
|
|
69
|
+
and prune snapshots. It resolves the project from its working directory, so
|
|
70
|
+
start it in the project you want to protect.
|
|
71
|
+
|
|
72
|
+
`dbsnap init` also writes `.agents/skills/dbsnap/SKILL.md` in the project.
|
|
73
|
+
Whether that skill is loaded automatically depends on the AI client; the skill
|
|
74
|
+
file and the MCP server are separate integrations.
|
|
75
|
+
|
|
76
|
+
## Commands
|
|
77
|
+
|
|
78
|
+
| Command | Purpose |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `dbsnap init` | Bind the project to a database. |
|
|
81
|
+
| `dbsnap status` | Check the database and snapshot storage. |
|
|
82
|
+
| `dbsnap save [tag]` | Create a snapshot; the tag is optional. |
|
|
83
|
+
| `dbsnap list` | List snapshot IDs and tags. |
|
|
84
|
+
| `dbsnap restore [tag-or-id]` | Restore a snapshot; omit the selector for the latest. |
|
|
85
|
+
| `dbsnap rollback` | Restore the latest snapshot. |
|
|
86
|
+
| `dbsnap prune --keep 5` | Remove older snapshots and retain the newest five. |
|
|
87
|
+
| `dbsnap diff before after` | Compare SQLite snapshot schemas and table row counts. |
|
|
88
|
+
|
|
89
|
+
`dbsnap list --json` and `dbsnap status --json` provide machine-readable
|
|
90
|
+
output. SQLite `diff` does not compare individual row contents; PostgreSQL and
|
|
91
|
+
MySQL/MariaDB snapshot diffs are not currently supported.
|
|
92
|
+
|
|
93
|
+
## Database requirements
|
|
94
|
+
|
|
95
|
+
| Database | Snapshot method | Requirements |
|
|
96
|
+
| --- | --- | --- |
|
|
97
|
+
| SQLite | Online backup and deduplicated chunks | No separate database client. |
|
|
98
|
+
| PostgreSQL | Server-side clone or `pg_dump` | Database creation privileges; PostgreSQL client tools for dump mode. |
|
|
99
|
+
| MySQL/MariaDB | Consistent logical dump | Compatible `mysql`/`mysqldump` or MariaDB client tools in `PATH`; transactional tables for consistent dumps. |
|
|
100
|
+
|
|
101
|
+
PostgreSQL server-side clones are stored on the database server. Use dump mode
|
|
102
|
+
when the snapshot needs to survive removal of that server's data volume.
|
|
103
|
+
|
|
104
|
+
## Safety
|
|
105
|
+
|
|
106
|
+
- The default host guard restricts operation to local and private-network
|
|
107
|
+
targets. MCP always uses that guard.
|
|
108
|
+
- Project binding checks that the current target matches the recorded database.
|
|
109
|
+
- Restore verifies the selected snapshot before applying it and, by default,
|
|
110
|
+
creates a safety snapshot first. If that snapshot cannot be created, restore
|
|
111
|
+
stops; the CLI has an explicit option to skip it.
|
|
112
|
+
|
|
113
|
+
dbsnap is intended for development workflows. Keep independent backups for
|
|
114
|
+
data you cannot afford to lose.
|
|
115
|
+
|
|
116
|
+
## Links
|
|
117
|
+
|
|
118
|
+
- [Repository and full documentation](https://github.com/farhan0431/db-snap)
|
|
119
|
+
- [MCP installation guide](https://github.com/farhan0431/db-snap/blob/main/INSTALL.md)
|
|
120
|
+
- [Report an issue](https://github.com/farhan0431/db-snap/issues)
|
|
121
|
+
|
|
122
|
+
MIT license.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farhan0431/db-snap",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "Instant physical database time-machine and MCP server for AI coding agents — git commit/checkout for your local database, powered by Rust.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|