Socket
Socket
Sign inDemoInstall

@nora-soderlund/cloudflare-d1-backups

Package Overview
Dependencies
0
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nora-soderlund/cloudflare-d1-backups

This is a package based heavily on [sqlite-dump for Python by simonw](https://github.com/simonw/sqlite-dump/blob/main/sqlite_dump/__init__.py) but modified to be suitable for the current state of the open alpha, experimental backend (beta), databases.


Version published
Weekly downloads
231
decreased by-39.37%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

cloudflare-d1-backups

This is a package based heavily on sqlite-dump for Python by simonw but modified to be suitable for the current state of the open alpha, experimental backend (beta), databases.

See Cretezy's fork for a direct D1 HTTP API version.

This script has been tested on a 50mb+ database.

npm i @nora-soderlund/cloudflare-d1-backups

Create a backup

Creating a backup creates a SQL file in the destination R2 bucket.

  • Install the package: npm install @nora-soderlund/cloudflare-d1-backups.
  • Call createBackup(D1Database, R2Bucket, CreateBackupOptions | undefined) from an execution context.

CreateBackupOptions

  • fileName: the file name, or a function that returns a string, for the SQL file in the R2 bucket, default is backups/${(new Date()).toUTCString()}.sql.
  • maxBodySize: the maximum body size for R2 bucket uploads in MB, this depends on your plan, unless you're using Enterprise with a custom size, leave this unset.
  • queryLimit: the row offset limit for each SELECT query, defaults to 1000. Alter depending on your row size.
  • excludeTablesData: name of the tables from which you do not want to include data, ['example1'] (Array)
  • tableNames: optional array of strings as table names, case sensitive

Restoring a backup

Assuming you've downloaded the backed up SQL file from your R2 bucket: npx wrangler d1 execute <database> --file=<backup.sql>

Example

See /example for an example worker.

FAQs

Last updated on 14 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc