A TypeScript CLI utility for database backups. Currently supports MySQL and PostgreSQL databases.
To install dependencies, run:
npm installCompile the TypeScript code:
npm run buildYou can run the CLI in several ways:
node dist/index.js backup --dbType <database-type>Replace <database-type> with either mysql or postgres.
npm run pg # For PostgreSQL backup
npm run mysql # For MySQL backupCreate 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_namesrc/
├── 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
- 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
0: Success1: Invalid database type2: Backup operation failed
To run tests:
npm testThis project is licensed under the MIT License. See the LICENSE file for details.