Created
August 7, 2017 03:04
-
-
Save zduymz/3362f2952d7db291d4ff4db9d3bf1a5b to your computer and use it in GitHub Desktop.
just a script
This file contains hidden or 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 | |
MYSQL_USER="root" | |
MYSQL_PASSWORD="password" | |
MYSQL_HOST="127.0.0.1" | |
mysql -u$MYSQL_USER -h$MYSQL_HOST -p$MYSQL_PASSWORD -e "show databases" | | |
grep -iv -E "(information_schema|Database)" > /tmp/db.txt | |
if [[ ! -f /tmp/db.ptr ]]; then | |
echo "1" > /tmp/db.ptr | |
fi | |
start_line=$(cat /tmp/db.ptr) | |
line_content=$(sed -n ${start_line}p /tmp/db.txt) | |
while [[ $line_content != "" ]]; do | |
echo "[+] Dumping database: $line_content" | |
mysqldump -u$MYSQL_USER -h$MYSQL_HOST -p$MYSQL_PASSWORD $line_content > ${line_content}.sql | |
((start_line++)) | |
echo $start_line > /tmp/db.ptr | |
line_content=$(sed -n ${start_line}p /tmp/db.txt) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment