Last active
July 29, 2019 08:11
-
-
Save 02Tea/ecf7f7cb17ebf37e65cb5b45a324c826 to your computer and use it in GitHub Desktop.
[MySQL - export and import database] #mysql #mysqldump #docker #mariadb #gunzip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DATE=$(date "+%Y%m%d%H%M%S") | |
DBUSER=$1 | |
DBPASS=$2 | |
DBNAME=$3 | |
mysqldump -u $DBUSER --password=$DBPASS $DBNAME | gzip > /path/to/dump/$DBNAME$DATE.sql.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DBUSER=$1 | |
DBPASS=$2 | |
DBNAME=$3 | |
DBFILE=$4 | |
mysql -u$DBUSER -p$DBPASS $DBNAME < $DBFILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DBUSER=$1 | |
DBPASS=$2 | |
DBNAME=$3 | |
DBFILE=$4 | |
gunzip -dc < $DBFILE | mysql -u$DBUSER -p$DBPASS $DBNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment