Skip to content

KunalSalunkhe12/SnapBase

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snapbase - Database Backup CLI

https://roadmap.sh/projects/database-backup-utility

A command-line interface (CLI) utility for backing up MySQL and MongoDB databases with support for compression and local storage.

Table of Contents

Features

✨ Key features of the Database Backup CLI:

  • Support for MySQL and MongoDB databases
  • Interactive configuration setup
  • Full database backups with compression
  • Local storage for backup files
  • Detailed activity logging
  • Database restore capabilities
  • Cross-platform compatibility

Prerequisites

Before installing the CLI, ensure you have:

Installation

Global Installation

Install the CLI globally via npm:

npm install -g snapbase

This allows you to run the snapbase command directly from the terminal.

snapbase configure --out ./backup-config.json

Local Installation

Or install locally in your project:

npm install snapbase

⚠️ After a local installation, you have to use npx to run the CLI:

npx snapbase configure --out ./backup-config.json

Configuration

Use the interactive configuration command to set up your database connection:

snapbase configure --out ./backup-config.json

This will create a configuration file with the following structure:

For MySQL:

{
  "type": "mysql",
  "host": "localhost",
  "port": "3306",
  "user": "your_username",
  "password": "your_password",
  "databaseName": "your_database",
  "backupDir": "./backup"
}

For MongoDB:

{
  "type": "mongodb",
  "uri": "mongodb://localhost:27017",
  "databaseName": "your_database",
  "backupDir": "./backup"
}

⚠️ Important: Add your configuration file to .gitignore to keep your credentials secure.

Usage

Configure

Set up your database connection settings:

snapbase configure [options]

Options:

  • --out <path>: Path to save configuration file (default: ./backup-config.json)

Backup

Create a database backup:

snapbase backup [options]

Options:

  • --config <path>: Path to configuration file (default: ./backup-config.json)

Restore

Restore a database from backup:

snapbase restore [options]

Options:

  • --config <path>: Path to configuration file (default: ./backup-config.json)

Logging

The CLI automatically logs all backup and restore activities to backup.log in the application directory. Each log entry includes:

  • Command executed
  • Start time
  • End time
  • Status
  • Time taken
  • Any errors encountered

Error Handling

The CLI includes comprehensive error handling for:

  • Database connection failures
  • Invalid configuration
  • Backup/restore operation failures

All errors are:

  • Displayed in the console with helpful messages
  • Logged to the activity log file
  • Include relevant error codes and suggestions

Limitations

Current limitations of the CLI:

  • Supports MySQL and MongoDB databases only
  • Full backups only (no incremental or differential backups)
  • Local storage only (no cloud storage options)
  • No notification system
  • No partial backup/restore functionality

Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

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


📦 NPM Package | 🐛 Report Bug | ✨ Request Feature

About

A Command-line interface (CLI) for backing up any type of database.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors