Registry / database / google-drive-mysql-backup

google-drive-mysql-backup

JSON →
library0.0.9jsnpmunverified

A Node.js module that automates MySQL database backups by dumping the database using mysqldump and uploading the resulting file to Google Drive. At version 0.0.9, it supports basic configuration for database connection and Google Drive folder selection, with an option to delete the local backup file after upload. It relies on Google API credentials via a service account private key JSON file. The package is simple and lightweight, but lacks TypeScript definitions and has minimal maintenance. Differentiators include a straightforward combined backup-and-upload workflow, but alternatives like `mysqldump` or `googleapis` may offer more flexibility.

npm install google-drive-mysql-backup
INSTALL
IMPORT
SIG · GOOGLE-DRIVE-MYSQL
G
google-drive-mysql-backup
databasejavascriptv0.0.9
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.

createAndUploadBackup
const createAndUploadBackup = require('google-drive-mysql-backup')
import createAndUploadBackup from 'google-drive-mysql-backup'
Package uses CommonJS; ESM import will fail unless using a bundler or dynamic import. The default export is a function.
createAndUploadBackup
import createAndUploadBackup from 'google-drive-mysql-backup'
If using a bundler that supports ESM for CJS packages, this will work. Otherwise, use require.

Creates a MySQL database dump and uploads it to Google Drive using a service account key file.

const createAndUploadBackup = require('google-drive-mysql-backup'); const dbConfig = { host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: process.env.DB_NAME ?? 'databasename' }; const googleDriveConfig = { parentId: process.env.DRIVE_PARENT_ID ?? 'root', deleteAfterUpload: false }; const privateKeyPath = process.env.GOOGLE_PRIVATE_KEY_PATH ?? './path/to/your/private_key.json'; createAndUploadBackup(privateKeyPath, dbConfig, googleDriveConfig) .then(() => console.log('Backup created and uploaded successfully')) .catch(err => console.error('Error during backup and upload:', err));
Debug
Known issues
gotchaRequires mysqldump command to be available on the system PATH
fix
Ensure mysqldump is installed (e.g., via mysql-client package) and accessible.
affects: >=0.0.0
gotchaGoogle Drive authentication uses a service account private key file; user must have the correct permissions and enable Google Drive API
fix
Enable Google Drive API in the Google Cloud Console and download the private key JSON for a service account with access to the Drive folder.
affects: >=0.0.0
deprecatedThe package is at version 0.0.9 and has not been updated in years; future updates may be needed for compatibility with newer Google APIs
fix
Consider using the official googleapis package directly for more control and updates.
affects: >=0.0.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open './path/to/your/private_key.json'
Private key JSON file path is incorrect or missing
fix
Provide the correct absolute or relative path to the downloaded private key JSON file.
Error: getaddrinfo ENOTFOUND localhost
MySQL host is not reachable (e.g., hostname not resolved or MySQL not running)
fix
Check the DB_HOST environment variable or dbConfig.host; ensure MySQL server is running and accessible
Upgrade
Version history
0.0.9latest on npm
Audit
Dependencies
googleapisrequiredUsed for authenticating and uploading to Google Drive
mysqlrequiredUsed for database connection and dumping
Agent activity
28 hits · last 30 days
node
26
OpenAI (training)
1
Resources
google-drive-mysql-backup — npm install google-drive-mysql-backup · libregistry