A simple shell script to automate common database tasks such as backing up and restoring a database. Supports both MySQL and PostgreSQL.
- Backup: Automatically create timestamped SQL backup files.
- Restore: Restore your database from a specified backup file.
- Configurable: Easily switch between MySQL and PostgreSQL via
config.sh.
Database-Management-Tool/ ├── db_manager.sh # Main script for backup and restore operations ├── config.sh # Configuration file with database credentials and settings ├── backups/ # Directory for storing backup files (created automatically) └── README.md # Project documentation
ruby Copy Edit
- Open
config.shand update the following parameters:- DB_TYPE: Set to
mysqlorpostgres. - DB_NAME: Your database name.
- DB_USER: Your database username.
- DB_PASSWORD: Your database password.
- DB_HOST: Typically
localhost. - DB_PORT: Default is
3306for MySQL or5432for PostgreSQL. - BACKUP_DIR: Directory where backups will be stored.
- DB_TYPE: Set to
- Clone the repository:
git clone https://github.com/yourusername/Database-Management-Tool.git cd Database-Management-Tool
Update the configuration: Modify config.sh with your database details.
Make the script executable:
bash Copy Edit chmod +x db_manager.sh Usage Backup Your Database Run the script with the backup command:
bash Copy Edit ./db_manager.sh backup A timestamped SQL backup file will be created in the backups/ directory.
Restore Your Database Run the script with the restore command followed by the path to the backup file:
bash Copy Edit ./db_manager.sh restore backups/your_backup_file.sql License This project is licensed under the MIT License.
yaml Copy Edit
- Enhancements:
- Add support for additional database types.
- Integrate email notifications on backup success or failure.
- Improve error handling and logging.
This Database Management Tool provides an automated way to backup and restore your databases and can be easily integrated into scheduled cron jobs for regular maintenance. Let me know if you'd like to move on to the next project or need additional features!