You can dump all the databases into a single .sql file like so:

mysqldump --all-databases > database_backup.sql

Or you can dump them individually to a directory with the date of backup to /home/ by using a for loop, such as this:

now=$(date +"%m_%d_%Y");mkdir /home/mysql.back.$now && for i in $(mysql -BNe 'show databases'| grep -v _schema);do echo $i; sudo mysqldump $i > /home/mysql.back.$now/$i.sql ; done 

Pin It on Pinterest

Share This