mkdir -p /backup/$(date +%Y%m%d)/ mysql -N -e 'show databases' | while read dbname; do mysqldump --complete-insert --routines --triggers --single-transaction "$dbname" > "/backup/$(date +%Y%m%d)/$dbname".sql; [[ $? -eq 0 ]] && gzip "/backup/$(date +%Y%m%d)/$dbname".sql; done