MySQL export. Table per file.

Way to save gzipped sql file with contain only one table. Some times good to have.

mysql -Nse 'select TABLE_SCHEMA, TABLE_NAME from TABLES' information_schema \
     | egrep -v 'information_schema|sys|mysql|performance_schema' \
     | awk '{print "mkdir -p "$1"; mysqldump -RQq "$1" "$2" \
     | gzip > "$1"/"$2".sql.gz"}' \
     | sh
Last part | sh do each command executable.
Result
# ls -la 
drwxr-xr-x 30 root root 6144 Aug 19 16:57 .
drwxr-xr-x  3 root root 6144 Aug 19 16:54 ..
drwxr-xr-x  2 root root 6144 Aug 19 16:51 client0_celery
...
drwxr-xr-x  2 root root 6144 Aug 19 16:56 client132_celery
# ls -1 client0_celery
celery_taskmeta.sql.gz
django_migrations.sql.gz
...
djcelery_periodictask.sql.gz
djcelery_taskstate.sql.gz

Comments

Popular posts from this blog

Redis with failover replication

FreeRadius and Google Workspace LDAP