Skip to content

Show backup progress and let the user cancel a backup - #39

Merged
necessarylion merged 6 commits into
mainfrom
backup-progress
Nov 7, 2026
Merged

necessarylion merged 6 commits into
mainfrom
backup-progress

Conversation

@necessarylion

Copy link
Copy Markdown
Owner

Problem

A backup only showed a loading state. The user could not see if it was still moving, and could not stop it.

What changed

  • Size and time: while the dump runs, the backend reads the size of the .part file once per second and sends it through a Tauri Channel. The UI shows Backing up… 48 MB, 0:32.
  • Current table: mysqldump and pg_dump now run with --verbose. DumpLog reads stderr line by line and finds the table. The UI shows Dumping table orders (12 of 40). The total comes from the table list of the tab. When the tool dumps more tables than the list has (other PostgreSQL schemas), only the count is shown. SQLite shows size and time only.
  • Errors still work: the verbose lines are not part of the error. Only the real error lines are kept (at most 20). If no line looks like an error, the last 5 lines are shown.
  • Cancel: a Cancel button (and Esc) calls cancel_dump. The backend kills the tool, waits for it to end, then deletes the .part file. An older backup at the target path is not touched. The status shows Backup cancelled, not an error.
  • tokio gets its macros feature (for select!). No new crates.

Tests

  • Rust: stderr parsing for mysqldump and pg_dump lines, error filtering, and a cancel test that checks the old backup stays and no .part file is left.
  • The end-to-end dump test now checks that progress was sent.
  • bun: progress text, cancel status, and an error while the dump runs (tests/Backup.test.ts).

Checks: bun run lint, bun run typecheck, bun test (380 pass), cargo clippy --all-targets (0 warnings), cargo test, cargo fmt. The end-to-end test also passed against MySQL and MariaDB in Docker. PostgreSQL was not run: the local pg_dump is version 15 and the Docker server is 17. The pg_dump line format comes from its source code.

A backup only showed a loading state. Now it shows the file size so far,
the time, and the table the dump tool works on. A Cancel button (or Esc)
stops the tool and deletes the half written file. An older backup at the
same path stays as it was.
A page load during a backup took the Cancel button away. Esc then stopped
the backup instead of the page load. The backup now has its own dumping
flag. Esc stops a running query or page load first.

A second backup in the same tab is refused, in the UI and in the backend.
Two backups would write the same side file.

The cancel test now cancels while sqlite3 really runs.
A page load or query that failed during a backup left cancellable and
cancelling set. Cancel then stayed on "Cancelling…", Esc could not stop
the backup, and the backup ended with "Query cancelled".

Now cancellableCall resets both flags in a finally. A cancel is kept in
its own queryCancelled mark, which run reads once.

cancel_dump no longer removes the entry of the tab. Only dump_database
removes it, so a cancel can never remove the entry of a newer backup.
The two conflicts were only import lists in commands.rs and service.rs.

Tauri can deliver the last progress message after the reply of the
command. That message showed "Backing up…" again after the backup ended,
also for later page loads and queries. showBackupProgress now does
nothing when no backup runs.
…wn side file

Escape stopped a running backup also when the user pressed it to close
a dialog, clear the table selection, or leave the editor or a menu. The
dialog then stayed open. Now Escape stops a backup only when it has no
other job there. Queries and page loads still stop on Escape as before.

Two tabs that backed up to the same file both wrote <path>.part. The side
file is now <path>.<pid>-<counter>.part.
@necessarylion
necessarylion merged commit 9a25a72 into main Nov 7, 2026
5 checks passed
@necessarylion
necessarylion deleted the backup-progress branch November 7, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant