Last active
March 23, 2023 07:08
-
-
Save mikaelz/33817bf7ee5120d0271fb355a3bfa2d8 to your computer and use it in GitHub Desktop.
MariaDB mysqldump via docker image
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 | |
DB_HOST="HOST" | |
DB_PORT=3306 | |
DB_USER="USER" | |
DB_PASS="PASS" | |
DB_NAME="NAME" | |
BACKUP_DIR="$HOME/Dropbox/sql" | |
DB_FILE="dump.sql" | |
if which docker >/dev/null 2>&1 ; then | |
rm -f $BACKUP_DIR/$DB_FILE.gz | |
docker run -it --name backup-mariadb mariadb:10.1 mysqldump --compress --add-drop-table --skip-comments --events --routines \ | |
-h $DB_HOST -P $DB_PORT -u $DB_USER -p$DB_PASS $DB_NAME -r $DB_FILE | |
docker cp backup-mariadb:dump.sql "$BACKUP_DIR/$DB_FILE" | |
docker rm backup-mariadb | |
gzip $BACKUP_DIR/$DB_FILE | |
rm -f $BACKUP_DIR/$DB_FILE | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment