MySQL each database from full b/fackup :)

#!/bin/bash
db=`find /var/lib/mysql -maxdepth 1 -type d|awk -F '/' '{print$5}'|grep -Ev 'mysql|perfomance_schema|^$'|sed 's/\@002d/-/g'`
#echo "$db"
echo "$db" | while read a; do
echo $a
sed -n "/^-- Current Database: \`"$a"\`/,/^-- Current Database: \`/p" /home/hosting_2017-10-03.sql > /home/backup/$a.sql
done

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.