Created
July 30, 2020 06:02
-
-
Save suryanto/a4176209354a98a1b0276a17f268ba65 to your computer and use it in GitHub Desktop.
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 | |
TMP="." | |
DB_USER="root" | |
DB_PASSWD="root" | |
DB="permata" | |
VERSION=`date +%F` | |
#First dump the structures | |
TABLES=`mysql --skip-column-names -e 'show tables' --user=${DB_USER} --password=${DB_PASSWD} ${DB}` | |
mysqldump --complete-insert --disable-keys --single-transaction --no-data --user=$DB_USER --password=$DB_PASSWD --opt $DB $TABLES > $TMP/$DB-$VERSION.sql | |
#Then dump the data, except for cache and temporary tables. | |
TABLES2=`echo "$TABLES" | grep -Ev "^(cache_.*|cachetags|sessions|watchdog)$"` | |
mysqldump --complete-insert --disable-keys --single-transaction --no-create-info --user=$DB_USER --password=$DB_PASSWD $DB $TABLES2 >> $TMP/$DB-$VERSION.sql | |
#Gzip everything | |
gzip -v $TMP/$DB-$VERSION.sql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment