Skip to content
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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions doc/api/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ added: v22.5.0

Constructs a new `DatabaseSync` instance.

### `database.backup(destination[, options])`
geeksilva97 marked this conversation as resolved.
Show resolved Hide resolved

<!-- YAML
added: REPLACEME
-->

* `destination` {string} The path where the backup will be created. If the file already exists, the contents will be
overwritten.
* `options` {Object} Optional configuration for the backup. The
following properties are supported:
* `source` {string} Name of the source database. **Default:** `'main'`.
* `target` {string} NAme of the target database. **Default:** `'main'`.
geeksilva97 marked this conversation as resolved.
Show resolved Hide resolved
* `rate` {number} Number of pages to be transmitted in each batch of the backup. **Default:** `100`.
* `progress` {Function} Callback function that will be called with the number of pages copied and the total number of
pages.

This method makes a backup of the database. The returned {Promise} will resolve when the backup is completed and will
reject if an error occurs. This method abstracts the [`sqlite3_backup_init()`][], [`sqlite3_backup_step()`][] and
[`sqlite3_backup_finish()`][] functions.

### `database.close()`

<!-- YAML
Expand Down Expand Up @@ -604,6 +624,9 @@ resolution handler passed to [`database.applyChangeset()`][]. See also
[`SQLITE_DETERMINISTIC`]: https://www.sqlite.org/c3ref/c_deterministic.html
[`SQLITE_DIRECTONLY`]: https://www.sqlite.org/c3ref/c_deterministic.html
[`database.applyChangeset()`]: #databaseapplychangesetchangeset-options
[`sqlite3_backup_finish()`]: https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupfinish
[`sqlite3_backup_init()`]: https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupinit
[`sqlite3_backup_step()`]: https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupstep
[`sqlite3_changes64()`]: https://www.sqlite.org/c3ref/changes.html
[`sqlite3_close_v2()`]: https://www.sqlite.org/c3ref/close.html
[`sqlite3_create_function_v2()`]: https://www.sqlite.org/c3ref/create_function.html
Expand Down
3 changes: 3 additions & 0 deletions src/env_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
V(__dirname_string, "__dirname") \
V(ack_string, "ack") \
V(address_string, "address") \
V(total_pages_string, "totalPages") \
V(remaining_pages_string, "remainingPages") \
V(progress_string, "progress") \
geeksilva97 marked this conversation as resolved.
Show resolved Hide resolved
V(aliases_string, "aliases") \
V(alpn_callback_string, "ALPNCallback") \
V(args_string, "args") \
Expand Down
Loading
Loading