-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sqlite: expose backup api #56253
base: main
Are you sure you want to change the base?
sqlite: expose backup api #56253
Conversation
6c61b4c
to
9b80c2d
Compare
632edd3
to
174ace5
Compare
174ace5
to
2aee11d
Compare
This comment mentions that The backup can be performed synchronously but I don't think it should be like that. I wonder if indeed this PR would be more suitable for async API. Any thoughts? Thanks in advance |
69a3bf3
to
bd43083
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56253 +/- ##
==========================================
+ Coverage 89.18% 89.20% +0.02%
==========================================
Files 662 662
Lines 191759 192178 +419
Branches 36911 36992 +81
==========================================
+ Hits 171017 171439 +422
+ Misses 13613 13562 -51
- Partials 7129 7177 +48
|
371f368
to
a92e692
Compare
a92e692
to
fa23c05
Compare
9069aa8
to
fa23c05
Compare
Failing test seems unrelated |
8e2caea
to
c532c58
Compare
That is not a requirement. |
0909d3e
to
7b15cae
Compare
--> | ||
|
||
* `sourceDb` {DatabaseSync} The database to backup. The source database must be open. | ||
* `destination` {string} The path where the backup will be created. If the file already exists, the contents will be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is assumed to be a filesystem path, then handling it the same as our other fs APIs would be ideal. Paths can be expressed as either strings, Buffer
, or file://
scheme URLs. If you're not familiar, there are internal utilities for normalizing these into a usable path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I will search for examples to see how to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense but I'd like to see this in another PR. DB locations are all defined as strings
in other parts of sqlite module - e.g. location in DatabaseSync.
We can have a PR dedicated to allowBuffer
and URLs all at once.
Do you think it makes sense?
Closes #55413
This PR exposes the SQLite Online Backup API, which allows database backup.
The API is inspired by better-sqlite3 https://github.com/WiseLibs/better-sqlite3/blob/master/docs/api.md#backupdestination-options---promise.
Multithreading caveats
As long as writes come from the same process and handle (
sqlite*
), the backup will continue progressing as expected. Other than that, it can cause the backup process to restart. From docs: