pgsqlio 0.1.0 → 0.1.1
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/package.json +1 -1
- package/readme.md +106 -17
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,30 +1,119 @@
|
|
|
1
1
|
# pgsqlio
|
|
2
2
|
|
|
3
|
-
Interactive PostgreSQL dump, restore,
|
|
3
|
+
Interactive CLI for PostgreSQL dump, restore, cleanup, and dropping databases.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
```bash
|
|
6
|
+
npx pgsqlio
|
|
7
|
+
# or
|
|
8
|
+
bunx pgsqlio
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+

|
|
12
|
+
|
|
13
|
+
Requires [Bun](https://bun.sh) ≥ 1.3 (recommended) or Node.js ≥ 26.4, plus `pg_dump` and `psql` on your `PATH`.
|
|
14
|
+
|
|
15
|
+
---
|
|
8
16
|
|
|
9
|
-
##
|
|
17
|
+
## Quick start
|
|
10
18
|
|
|
11
19
|
```bash
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
bunx pgsqlio
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
You’ll get a terminal UI with sticky branding and a menu. Use ↑/↓ and Enter. Esc goes back. Ctrl+C quits.
|
|
24
|
+
|
|
25
|
+
Connection URLs work with or without a database name:
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
postgresql://user:password@host:5432
|
|
29
|
+
postgresql://user:password@host:5432/mydb
|
|
30
|
+
postgresql://postgres@127.0.0.1
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Commands (interactive menu)
|
|
36
|
+
|
|
37
|
+
There are no subcommands — start `pgsqlio` and pick an action.
|
|
38
|
+
|
|
39
|
+
### Dump
|
|
40
|
+
|
|
41
|
+
Backup one or more databases.
|
|
42
|
+
|
|
43
|
+
1. Enter connection URL
|
|
44
|
+
2. **All databases** or **Select databases**
|
|
45
|
+
3. If multiple: **Separate files** or **Single file**
|
|
46
|
+
4. Watch per-database progress
|
|
47
|
+
|
|
48
|
+
| Mode | Output |
|
|
49
|
+
| -------- | ------------------------------------- |
|
|
50
|
+
| Separate | `backup_<dbname>_YYYYMMDD_HHMMSS.sql` |
|
|
51
|
+
| Single | `backup_combined_YYYYMMDD_HHMMSS.sql` |
|
|
52
|
+
|
|
53
|
+
Combined files create missing databases on restore and switch with `\connect`. Dumps include `--clean --if-exists`.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### Restore
|
|
58
|
+
|
|
59
|
+
Import a `.sql` backup.
|
|
60
|
+
|
|
61
|
+
1. Enter connection URL
|
|
62
|
+
2. Enter path to the `.sql` file
|
|
63
|
+
3. Choose how to apply:
|
|
64
|
+
|
|
65
|
+
| Option | When to use |
|
|
66
|
+
| ------------------------------ | --------------------------------------------------------- |
|
|
67
|
+
| **Wipe schemas, then restore** | Target already has objects / retry after a failed restore |
|
|
68
|
+
| **Restore as-is** | Empty databases |
|
|
69
|
+
|
|
70
|
+
Combined dumps: missing DBs are created automatically, then the file is loaded.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
### Cleanup
|
|
75
|
+
|
|
76
|
+
Empty one database’s `public` schema (keeps the database).
|
|
77
|
+
|
|
78
|
+
1. Enter URL **including** `/dbname`
|
|
79
|
+
2. Confirm
|
|
80
|
+
|
|
81
|
+
Runs:
|
|
82
|
+
|
|
83
|
+
```sql
|
|
84
|
+
DROP SCHEMA public CASCADE;
|
|
85
|
+
CREATE SCHEMA public;
|
|
15
86
|
```
|
|
16
87
|
|
|
17
|
-
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### Drop databases
|
|
91
|
+
|
|
92
|
+
Permanently delete selected databases.
|
|
93
|
+
|
|
94
|
+
1. Enter connection URL
|
|
95
|
+
2. Select databases (checkboxes)
|
|
96
|
+
3. Confirm
|
|
97
|
+
|
|
98
|
+
Active connections are terminated first. `postgres` and `template*` cannot be dropped.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Keyboard
|
|
18
103
|
|
|
19
|
-
|
|
104
|
+
| Key | Action |
|
|
105
|
+
| ------ | ------------------ |
|
|
106
|
+
| ↑ / ↓ | Move |
|
|
107
|
+
| Enter | Confirm |
|
|
108
|
+
| Space | Toggle checkbox |
|
|
109
|
+
| a | Select all (lists) |
|
|
110
|
+
| Esc | Back |
|
|
111
|
+
| Ctrl+C | Quit |
|
|
20
112
|
|
|
21
|
-
|
|
22
|
-
2. **Restore** — enter URL + `.sql` path → confirm
|
|
23
|
-
3. **Cleanup** — enter URL → confirm destructive reset
|
|
24
|
-
4. **Quit**
|
|
113
|
+
---
|
|
25
114
|
|
|
26
115
|
## Notes
|
|
27
116
|
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
117
|
+
- Use a role with rights to dump, create, and drop as needed.
|
|
118
|
+
- Prefer **Wipe schemas, then restore** if you see “already exists” errors.
|
|
119
|
+
- Host-only URLs (no `/dbname`) are fine for Dump / Drop; Cleanup needs a specific database in the URL.
|