Registry / database / mongodb-backup-cloud

mongodb-backup-cloud

JSON →
library1.0.8jsnpmunverified

A TypeScript library (v1.0.8) for automating MongoDB database backups and uploading them to GitHub or Google Drive. Supports one-time backups, recurring backups via cron schedules, and optional cleanup of old backup files. Requires MongoDB Database Tools installed on the host. Differentiates from generic backup tools by combining backup and cloud upload into a single workflow with TypeScript types.

npm install mongodb-backup-cloud
INSTALL
IMPORT
SIG · MONGODB-BACKUP-CLO
M
mongodb-backup-cloud
databasejavascriptv1.0.8
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.

Backup
import { Backup } from 'mongodb-backup-cloud'
const Backup = require('mongodb-backup-cloud')
TypeScript-friendly named export; default import not available.
Upload
import { Upload } from 'mongodb-backup-cloud'
const Upload = require('mongodb-backup-cloud')
ESM-only; named export.
URIOptions
import { URIOptions } from 'mongodb-backup-cloud'
TypeScript interface; used for type narrowing.
DirectOptions
import { DirectOptions } from 'mongodb-backup-cloud'
TypeScript interface for host/port backup options.
GDriveOptions
import { GDriveOptions } from 'mongodb-backup-cloud'
TypeScript interface for Google Drive upload options.
GithubOptions
import { GithubOptions } from 'mongodb-backup-cloud'
TypeScript interface for GitHub upload options.

Shows a complete backup configuration with URI, cron schedule, and old backup cleanup.

import { Backup, URIOptions } from 'mongodb-backup-cloud'; const uriOptions: URIOptions = { uri: 'mongodb://localhost:27017/', database: 'test_db', collection: 'test_collection', outputPath: './test_backup_path', removeOldBackups: true, oldBackupPath: './old_backup', schedule: '00 00 00 * * *', scheduleCallback: (args) => { console.log('Backup done', args); } }; Backup.withConnectionString(uriOptions);
Debug
Known issues
gotchaMongoDB Database Tools must be installed and in PATH before using this library.
fix
Install mongodb-database-tools from MongoDB official site and add to PATH.
affects: all
gotchaGoogle Drive upload requires OAuth 2.0 credentials; refresh token must be obtained manually.
fix
Follow the referenced blog guide to get clientId, clientSecret, and refreshToken.
affects: all
gotchaGitHub upload requires a personal access token with repo and read:user scopes.
fix
Generate token with repo and read:user scopes in GitHub developer settings.
affects: all
gotchaCron schedule uses 6-field format (seconds not supported), not the standard 5-field cron.
fix
Use cron format: 'ss mm hh day month dayOfWeek' (e.g., '00 00 00 * * *' for midnight).
affects: all
gotchaThe package does not validate options before execution; invalid options cause runtime errors.
fix
Ensure all required fields are provided correctly based on the option type.
affects: all
Errors
Common errors & fixes
Error: spawn mongodump ENOENT
MongoDB Database Tools not installed or not in PATH.
fix
Install mongodb-database-tools and ensure mongodump is accessible.
Error: Invalid OAuth 2.0 credentials
Invalid Google Drive OAuth clientId, clientSecret, or refreshToken.
fix
Regenerate OAuth credentials following the referenced guide.
Error: Cannot find module 'mongodb-backup-cloud'
Package not installed or used in CommonJS environment without correct import.
fix
Run 'npm install mongodb-backup-cloud' and use ESM import syntax.
Error: Invalid schedule format
Cron expression does not match 6-field format.
fix
Use format 'ss mm hh day month dayOfWeek' (e.g., '00 00 00 * * *').
Upgrade
Version history
1.0.8latest on npm
Audit
Dependencies
mongodb-database-toolsrequiredrequired for mongodump/mongorestore commands
Agent activity
11 hits · last 30 days
node
10
Resources
mongodb-backup-cloud — npm install mongodb-backup-cloud · libregistry