Created
August 10, 2025 11:42
-
-
Save stefanpejcic/19364cd554bdc07f1b407dbf52531424 to your computer and use it in GitHub Desktop.
Export OpenPanel mysql database tables
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 --database=panel -e "SHOW TABLES;" -s --skip-column-names | \ | |
| while read table; do | |
| echo "Dumping $table" | |
| echo "SHOW CREATE TABLE \`$table\`;" >> panel_full_dump.sql | |
| mysql --database=panel -e "SHOW CREATE TABLE \`$table\`\G" | \ | |
| grep -v '^\*\*\*' >> panel_full_dump.sql | |
| mysql --database=panel -e "SELECT * FROM \`$table\`;" --skip-column-names | \ | |
| awk -v tbl="$table" 'BEGIN {print "INSERT INTO `" tbl "` VALUES"} \ | |
| {printf "("; for(i=1; i<=NF; i++) { printf "\"%s\"", $i; if(i<NF) printf ","; } print "),"} END {print ";"}' >> panel_full_dump.sql | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment