Skip to content

Show the transfer of a SQL Server backup in the run instead of its 100 percent - #229

Merged
Skyfay merged 1 commit into
devfrom
Skyfay/mssql-download-progress
Nov 24, 2026
Merged

Skyfay merged 1 commit into
devfrom
Skyfay/mssql-download-progress

Conversation

@Skyfay

@Skyfay Skyfay commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Problem

A SQL Server backup over SFTP or a shared folder runs in two parts: BACKUP DATABASE writes the .bak on the server, then DBackup fetches it. For a large database the fetch often takes longer than the backup itself. During the whole fetch the run summary showed the last message of SQL Server, "100 % by SQL Server" with no time left, so the run looked stuck at the end of the dump. The live detail line also measured its speed from the start of the dump, which counted the time on the server as a slow transfer.

Solution

The adapter now tells the runner when it starts to fetch a .bak and how large it is on the server. The runner keeps that with the dump of the database, and the summary measures the fetch against it: share, bytes, speed and time left.

Details:

  • dumpOne takes an optional onTransfer(totalBytes) callback. MSSQL calls it with the size from host.stat before the SFTP download, and with the size of the file in the shared folder before it copies it. A server that does not tell the size fetches as before, without a transfer to follow.
  • DumpState and DumpRecord carry an optional transfer with the total and its start, so it lands in the metadata of the run like the rest of the dump.
  • progressOf in run-dumps.ts checks a transfer before the SQL Server percent, and shows "x of y fetched at z/s" with the time left.
  • watchDumpSize measures the speed from when the file appeared and says "written" instead of "dumped".

Testing

  • pnpm validate passes, with new unit tests for the summary of a transfer, the metadata of one, and the size MSSQL reports over SSH and from a shared folder.
  • Ran the lab job "Lab SQL Server 2022 to FTP" with a 2.77 GB database of random data on mssql-2022, fetched over SFTP from the lab host. Early in the fetch the summary showed "4 % · 123.5 MB of 2.8 GB fetched at 8.8 MB/s, about 5m 7s left", the fetch took 4m 45s, and the recorded bytes matched the size on the server for every database.

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/services/history/run-dumps.ts 57.14% 0 Missing and 6 partials ⚠️
src/lib/runner/steps/dump-databases.ts 33.33% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@Skyfay
Skyfay merged commit 75d28aa into dev Nov 24, 2026
21 checks passed

This branch was previously deployed

1 inactive deployment
e2e — 4f5ac746 Deployed Nov 24, 2026 by Skyfay via Approve #168
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