Skip to content

⛩️ A TypeScript CLI utility for database backups. Currently supports MySQL and PostgreSQL databases.

Notifications You must be signed in to change notification settings

Mx444/oclif-postgres-mysql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📦 db-backup-cli

DB Logo

A TypeScript CLI utility for database backups. Currently supports MySQL and PostgreSQL databases.

🚀 Installation

To install dependencies, run:

npm install

🔨 Build

Compile the TypeScript code:

npm run build

🛠️ Usage

You can run the CLI in several ways:

Using the CLI directly

node dist/index.js backup --dbType <database-type>

Replace <database-type> with either mysql or postgres.

Using npm scripts

npm run pg    # For PostgreSQL backup
npm run mysql # For MySQL backup

⚙️ Configuration

Create a .env file in the project root with the following environment variables:

DB_USER=your_username
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=database_port
DB_NAME=database_name

🧩 Project Structure

src/
├── commands/       # CLI commands
│   └── backup.ts   # Backup command implementation
├── config/         # Configuration
│   └── index.ts    # Environment variables setup
├── index.ts        # Main entry point
├── lib/            # Core functionality
│   └── backupFunctions.ts  # Database backup implementations
└── utils/
    └── logger.ts   # Logging utilities

🔍 Features

  • Multiple Database Support: Backup both MySQL and PostgreSQL databases
  • Timestamped Backups: Each backup file includes a timestamp
  • Error Handling: Comprehensive error handling with appropriate exit codes
  • Logging: Detailed logging of backup operations

📋 Exit Codes

  • 0: Success
  • 1: Invalid database type
  • 2: Backup operation failed

🧪 Testing

To run tests:

npm test

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.

About

⛩️ A TypeScript CLI utility for database backups. Currently supports MySQL and PostgreSQL databases.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published