Talk:MySQL - dumping and restoring

From WPKG | Open Source Software Deployment and Distribution
Jump to: navigation, search

Wouldn't it be easier to do this in a for loop instead? Something like this:

for i in $(echo 'SHOW DATABASES;' | mysql -u<username> -p<password> | grep -v '^Database$'); do mysqldump --<some-options-for-mysqldump> $i > db-backup_$i.sql done

-- Tor (

Sure it would. If you can do the dump right now. In that case, dumping the database and restoring it a second later doesn't make sense anyway ;) The example shown on a previous page is useful if you have a full dump already i.e. from a backup made one week or month earlier.