#!/bin/bash # destination for the backups # mysqlbackup.lst needs to be in this dir, # and list all the db names you want to transfer dest="/home/user/downloads"; user="user"; pass="passwd"; host1="host1.net"; host2="host2.net"; for db in `cat $dest/mysqlbackup.lst` do echo "dumping $db..." /usr/bin/mysqldump -u $user -h $host1 -p$pass $db > $dest/$db.sql echo "creating $db locally..." /usr/bin/mysqladmin -u $user -p$pass create $db echo "importing $db.sql to $db..." /usr/bin/mysql -u $user -h $host2 -p$pass $db < $dest/$db.sql echo "removing $dest/$db.sql..." rm $dest/$db.sql done
Friday, February 22, 2008
shell script to copy all MySQL databases from one server to another
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment