Repository navigation
feat(utilities): Backup & Restore — commands per engine, with saved defaults - #477
Merged
Merged
Conversation
…efaults A new Utilities tool that writes the backup and restore commands for the chosen connection. Fox Schema writes them and does not run them. - Where the command runs comes first, because it decides what "folder" means: pg_dump writes where it runs, SQL Server's BACKUP DATABASE on the database server, Oracle Data Pump into a DIRECTORY object, Redshift keeps a snapshot in AWS. - Every engine Fox Schema connects to (16): pg_dump/pg_restore, ysql_dump, CockroachDB BACKUP/RESTORE, Redshift snapshots via the AWS CLI, mysqldump / mariadb-dump (TiDB without routines), SQL Server BACKUP DATABASE (COPY_ONLY), Azure SQL SqlPackage, Oracle expdp/impdp, Db2 BACKUP/RESTORE and db2look, ClickHouse BACKUP to a disk, DuckDB EXPORT, sqlite3 .backup/.dump, mongodump, redis-cli --rdb. - Options per engine: folder, format, what to back up (everything, structure only (DDL), rows only), compression, only the connection's schema, only some tables. Restores that would overwrite live data say so; CockroachDB, ClickHouse and Azure SQL restore beside it under a new name. - No command contains a password; each says how its tool asks for one. - Folder, format and scope save as the user's default per engine: metadata migration 26 (backup_settings), GET/PUT /api/backup-settings, re-validated on every read. Pure command generation in @foxschema/sql (one provider file per engine, registry, facade); the server stores defaults; the panel is features/utilities/components/BackupRestorePanel.tsx. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: e38af7e4-9a34-4dae-96dc-a9f6ef3b4a1f) |
Contributor
Test IDsAdded (27)
|
The file name is the reader's to edit, and expdp/impdp took DIRECTORY=, DUMPFILE= and LOGFILE= unquoted, as did the Db2 commands the database name: a space or `;` there split the copied command. Each is now one shell word, bare when it is plainly safe, so ordinary commands read as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: a3dcd837-3c82-4c21-aec1-971a7f635576) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A new Backup & Restore tool in the Utilities workspace. It writes the backup and restore commands for the chosen connection, on every engine Fox Schema connects to. Like Database Access, Fox Schema writes the commands and never runs them.
What a user sees
Where it runs, first. That decides what "folder" means:
A folder typed on the wrong side of that line is how a backup "succeeds" into nowhere.
Options, where the engine has them:
Backup and Restore blocks with Copy. SQL-language engines also get "Open in SQL Editor" on this connection.
Notes:
"Save as my default for " keeps folder, format, scope, compression and schema limit per user and engine, server-side.
Screenshots:
apps/e2e/screenshots/backup-restore-postgres_*.pngandbackup-restore-sqlserver_*.png(local run).Design
@foxschema/sql, pure generation:modules/utilities/backup.ts(facade: settle settings, name the file, build);backup.registry.ts;backup-helpers.ts(shell, SQL and path quoting);providers/<engine>/<engine>.backup.tsper engine, followingdocs/CONVENTIONS.md.backup_settings(user_id,dialect, JSONsettings, PK both). Append-only.GET /api/backup-settingsandPUT /api/backup-settings/:dialect, signed-in user only. The contract test is updated (113 → 115).normalizeBackupSettingson every read and write, so a stale or hand-edited row comes back as something the engine can honour.BackupRestorePanel.tsx,shared/api/backupApi.ts, wired intoUtilitiesView.Verification
backup.test.ts):'and];DIALECTScovered.backup-settings.service.test.ts): save, settle, replace, per-user isolation, unknown engine, a damaged row.pg_dump(custom) andpg_restore, and plain +gzipwithpsql, run inside the container into scratch databases. 45 of 45 tables came back. Cleaned up.BACKUP DATABASE, thenRESTORE VERIFYONLYon the file, through the product's SQL runner (backup-commands-dialects.test.ts).EXPORT DATABASEran (schema.sqlandload.sqlwritten).backups.allowed_disk, which the suite reports as a skip.db2 backup/restore, db2look: every flag used appears in the tool's own help in its container. Running them needs the containers' passwords, which I did not read.backup-restore-ui.test.ts), 3 of 3: says where pg_dump runs; the command has the connection's user and no password; a saved folder survives a reload; SQL Server's backup opens in the SQL editor.npm run typecheck(web + e2e), the unit project (4,974) and web-ui (335): pass. ESLint: clean. Both new suites are registered inrun-all.mjs.🤖 Generated with Claude Code
Note
Medium Risk
New persisted user settings and API surface behind auth; generated restore scripts can be destructive if run blindly, though the product still does not execute backups.
Overview
Adds Backup & Restore to Database utilities: a new pane that generates backup/restore commands for the workspace connection, shows where they run (client vs server vs cloud), and exposes folder, format, scope, compression, schema/table filters, copy, and Open in SQL Editor for SQL engines.
@foxschema/sqlgains a backup module (buildBackupCommands, settings normalization, registry) with per-dialect builders for every supported engine; commands never embed passwords.Server: migration 26 (
backup_settingsper user/dialect), authenticatedGET /api/backup-settingsandPUT /api/backup-settings/:dialect, with settings normalized on read/write.Tests: unit coverage for SQL generation, panel behavior, and settings service; browser e2e for the panel and saved defaults; e2e that runs generated SQL on SQL Server, CockroachDB, ClickHouse, and DuckDB when configured.
test:backupandrun-all.mjsregister the new suites; test IDs/docs updated.Reviewed by Cursor Bugbot for commit 91dc223. Bugbot is set up for automated code reviews on this repo. Configure here.