How do I run a mysqldump on my MySQL Linux server?

The following script can be used to create a mysqldump by schema name:


TODAY=$(date +%m”-“%d”-“%Y)
HOSTNAME=$(hostname -s)

for db in $(echo “show databases;” | /usr/bin/mysql -uroot | egrep -v “+|^Database”); do

/usr/bin/mysqldump –opt -d -R -uroot -h $HOSTNAME –database $db > /data/mysql-backup/$HOSTNAME-$TODAY.$db-shell.dmp

/usr/bin/mysqldump –opt -vvv -n -t -q -R -uroot -h $HOSTNAME –database $db | gzip -c -v > /data/mysql-backup/$HOSTNAME-$TODAY.$db.dmp.gz


Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top