This is a shell script that allows you to perform various actions on a database using automation with Docker. The script provides an easy-to-use command-line interface to interact with the database.
Before running this script, ensure that you have Docker installed on your system and the necessary Docker images or containers for the database you want to manage.
To use this script, follow the instructions below:
./database.sh [ACTION] [PATH]
Replace [ACTION]
with one of the following options:
c
orcreate
: Create a new database.e
orexport
: Export the database.i
orimport
: Import the database from the file specified in[PATH]
.d
ordelete
: Delete an existing database.r
orrecreate
: Delete the existing database and create a new one.p
orprint_uri
: Print the database URI.ch
orcheck
: Check the database connection.
To create a new database, run the following command:
./database.sh create
To export the database, use the following command:
./database.sh export
To import the database from a specific file, provide the file PATH
as follows:
./database.sh import PATH
Replace PATH
with the path to the file containing the database you want to import.
To delete an existing database, use the following command:
./database.sh delete
To delete the existing database and create a new one, use the following command:
./database.sh recreate
To print the database URI, use the following command:
./database.sh print_uri
To check the database connection, use the following command:
./database.sh check
- Create a new database:
./database.sh create
- Export the database:
./database.sh export
- Import the database from a file:
./database.sh import /path/to/database_file.sql
- Delete an existing database:
./database.sh delete
- Delete the existing database and create a new one:
./database.sh recreate
- Print the database URI:
./database.sh print_uri
- Check the database connection:
./database.sh check
- Make sure to adjust the script according to your specific database configuration and Docker setup.
- Use the script at your own risk, and ensure you have proper backups before performing any destructive actions.
If you have any questions or face issues, feel free to contact me.
Happy database management! 😄