Git Product home page Git Product logo

shell-script-for-automating-database-duplication's Introduction

Shell Script for Automating MySQL Database Duplication

The following script automates the creation of a test database by duplicating an existing database. It exports the schema (and optionally the data), creates a new test database, and imports the schema/data into the test database.

Table of Contents

Prerequisites

  • MySQL Server: One of the scripts is designed for MySQL databases. Ensure you have MySQL server installed and accessible.
  • .env File: Database credentials and other configurations are managed through a .env file in the project directory.

Installation

Clone this repository to your local machine using the following command:

git clone https://github.com/NaviteLogger/Shell-Script-for-Automating-MySQL-Database-Duplication.git
cd Shell-Script-for-Automating-MySQL-Database-Duplication

Ensure the script file (duplicate_db.sh) is executable:

chmod +x duplicate_mysql_db.sh

Configuration

Create a .env file in the root directory of this project with the following content, replacing the placeholders with your actual database credentials and names:

DB_USER=myuser
DB_PASS=mypassword
SOURCE_DB=mydatabase
TEST_DB=mytestdatabase

Usage

To run the script:

./duplicate_mysql_db.sh

The script will prompt you for your MySQL password (if not provided in the .env file), export the specified source database, create (and drop if it already exists) the test database, and then import the data into the test database.

Security

This script prompts for the database password to avoid storing sensitive information in the script or the .env file. Ensure your .env file is not tracked by version control systems (e.g., listed in .gitignore) to keep your credentials secure.

Contributing

Contributions to improve the script or address issues are welcome. Please feel free to submit a pull request or open an issue in the repository.

License

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

shell-script-for-automating-database-duplication's People

Contributors

navitelogger avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.