Skip to content

A command-line utility for automated database backup and restore operations. Supports both SQL and MongoDB databases with features including AES encryption, compression, and progress tracking. Built in Java, this tool simplifies database maintenance tasks through an easy-to-use CLI interface.

Notifications You must be signed in to change notification settings

GustavoLyra23/Database-Backup-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database Backup & Restore CLI Utility

A command-line utility for performing database backups and restorations, supporting both SQL and MongoDB databases with encryption and compression capabilities.

Overview

This Java-based CLI tool automates database backup and restore operations with built-in support for encryption, compression, and progress tracking. It provides a straightforward interface for managing database backups across different database types.

Features

  • Multi-database support (SQL and MongoDB)
  • AES encryption for secure backups
  • Automatic compression
  • Real-time progress monitoring
  • Flexible restoration options

Prerequisites

  • Java 21 or later
  • Access to command-line interface
  • Database connection credentials

Installation

git clone https://github.com/YourUsername/DatabaseBackupProject.git
cd DatabaseBackupProject

Usage

Key Management

Generate a new encryption key:

--generate key

Database Configuration

Set database connection parameters:

--db <dbType> --url <url> [--password <password>] [--user <user>] [--dbName <database name>]

Backup Operations

Create a new backup:

--do backup [--entity [entity1, entity2]] [--key <encryption key>]

Restore Operations

Restore from backup:

--restore --foldertypedb <mongo/sql> --folderName <folder name> [--saves [save1, save2]] [--key <encryption key>]

Backup Management

List available backups:

--list [mongo/sql] [--folder <folder name>]

View available commands:

--help

Security

The utility uses AES encryption for backup security. When using encryption:

  • Store encryption keys securely
  • Required for both backup and restore operations
  • Cannot recover encrypted backups without the original key

Example Workflow

  1. Configure database connection:
--db sql --url jdbc:mysql://localhost:3306 --user admin --password securepass --dbName production
  1. Create encrypted backup:
--do backup --entity [users, accounts] --key MY_SECURE_KEY
  1. Restore specific tables:
--restore --foldertypedb sql --folderName backup_20250128 --key MY_SECURE_KEY

Backup Storage

Backups are automatically organized in the user's home directory:

~/backups/
├── sql/
│   └── backup_yyyyMMdd_HHmmss.sql.gz
└── mongo/
    └── backup_yyyyMMdd_HHmmss.json.gz

Contributing

We welcome contributions to improve the utility. Please submit issues and pull requests through our GitHub repository.

Security Notice

This tool performs critical database operations. Always test thoroughly in a non-production environment before using in production systems.

About

A command-line utility for automated database backup and restore operations. Supports both SQL and MongoDB databases with features including AES encryption, compression, and progress tracking. Built in Java, this tool simplifies database maintenance tasks through an easy-to-use CLI interface.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published