So you need to backup all the MySQL databases on your system? This is easy with MySQL’s mysqldump. The quickest solution is to
dump all databases to one ugly file:
mysqldump -u root -p --all-databases > $(hostname)-everything.sql
A more organized approach is to loop through all your databases and dump individual files. A Bash script example:
#!/bin/bash read -p "Enter MySQL user: " -s DBUSER read -p "Enter MySQL $DBUSER password: " DBPASS DATE=$(date +'%m%d%Y') # dump all databases to current path for DB in $(echo "show databases" | mysql -u$DBUSER -p$DBPASS | grep -v Database); do mysqldump -u$DBUSER -p$DBPASS $DB > $DB-$DATE.sql || exit $? gzip $DB-$DATE.sql || exit $? done && exit $?