Registry / storage / strapi-db-sqlite-cloud-backup

strapi-db-sqlite-cloud-backup

JSON →
library0.2.21jsnpmunverified

Backup script for Strapi SQLite DB files with scheduled uploads to Yandex Disk or Google Drive. Current version 0.2.21, requires Node 18-20. Automates configuration via npx init command, supports PM2 process manager for cron scheduling. Differentiator: specifically tailored for Strapi's SQLite backend, supports both Yandex and Google Drive, and includes automatic cleanup of old backups both locally and in the cloud. Uses winston for logging, googleapis for Drive, and yandex-disk for Yandex upload.

npm install strapi-db-sqlite-cloud-backup
INSTALL
IMPORT
SIG · STRAPI-DB-SQLITE-C
S
strapi-db-sqlite-cloud-backup
storagejavascriptv0.2.21
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (script itself)
npx strapi-db-sqlite-cloud-backup run
npm run strapi-db-sqlite-cloud-backup
Package is not a library but a CLI tool; use npx or pm2 to run the backup script.
init command
npx strapi-db-sqlite-cloud-backup init
npx strapi-db-sqlite-cloud-backup --init
Use 'init' subcommand to create .env and ecosystem.config.js files.
pm2 integration
pm2 start ecosystem.config.js
pm2 start node_modules/strapi-db-sqlite-cloud-backup/backup.js
Use the ecosystem.config.js file generated by init; direct script path without ecosystem file misses environment variables.

Install the package, initialize configuration, set environment variables for Google Drive, and run a one-time backup manually.

npm install strapi-db-sqlite-cloud-backup npx strapi-db-sqlite-cloud-backup init # Edit .env with your cloud credentials echo "GOOGLE_DRIVE_ENABLED=true GOOGLE_DRIVE_FOLDER_ID=your_folder_id GOOGLE_CREDENTIALS_PATH=./credentials.json YANDEX_DISK_ENABLED=false DB_PATH=../.tmp DB_NAME=data.db MAX_BACKUPS=10" > .env npx strapi-db-sqlite-cloud-backup run
Debug
Known issues
gotchaThe backend (Strapi) must be stopped or in read-only mode while backing up, otherwise the SQLite file copy may be inconsistent. The script copies the file without locking the database.
fix
Stop Strapi before backup, or ensure SQLite is not being written to (e.g., use a replica).
affects: >=0.0.0
gotchaGoogle Drive credentials file path must be absolute or relative to the directory where pm2 runs. Using a relative path in pm2 ecosystem.config.js may break if pm2 is started from a different working directory.
fix
Use absolute path for GOOGLE_CREDENTIALS_PATH, or set working directory in ecosystem.config.js with cwd option.
affects: >=0.2.0
breakingNode.js engine requirement >=18.0.0 <=20.x.x. Using Node 21+ may cause incompatibilities with dependencies (like googleapis).
fix
Use Node 18 or 20. Run `nvm use 18` or downgrade via nvm.
affects: >=0.2.0
deprecatedThe 'yandex-disk' npm package may be unmaintained and could break with API changes. Yandex Disk OAuth tokens expire and require renewal.
fix
Consider using only Google Drive; or manually renew Yandex token every year.
affects: >=0.0.0
gotchaThe MAX_BACKUPS variable applies only to local backup directory deletion, not to cloud storage cleanup (only Yandex Disk supports cloud cleanup). Google Drive backups are never deleted by the script.
fix
Implement your own cleanup for Google Drive, or set MAX_BACKUPS to a high value to avoid accumulation.
affects: >=0.2.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open '.../data.db'
DB_PATH or DB_NAME environment variables not set correctly, or Strapi db file does not exist at the specified path.
fix
Verify the path: Strapi default is .tmp/data.db relative to backend root. Ensure DB_PATH includes trailing slash or proper concatenation.
Error: Cannot find module 'googleapis'
googleapis package not installed; it is an optional dependency but required for Google Drive uploads.
fix
Run `npm install googleapis` in your project.
Error: getaddrinfo ENOTFOUND www.googleapis.com
No internet connectivity or DNS resolution failure when uploading to Google Drive.
fix
Check network connection and ensure outbound HTTPS (443) is allowed.
Error: invalid_grant
Google service account credentials expired or invalid or OAuth scope missing.
fix
Re-download credentials JSON from GCP Console and ensure the service account has Drive API enabled and folder shared with the service account email.
Upgrade
Version history
0.2.21latest on npm
Audit
Dependencies
winstonrequiredlogging framework used by the script
googleapisoptionalGoogle Drive API client for uploading backups
yandex-diskoptionalYandex Disk API client for uploading backups
pm2optionalprocess manager for scheduled runs (recommended but not required for manual runs)
Agent activity
20 hits · last 30 days
node
18
Resources