Created
July 16, 2010 09:55
-
-
Save jesseadams/478194 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'mysql' | |
begin | |
puts "Dumping mysql databases..." | |
system("rm -f /root/mysql/*") | |
mysql = Mysql.real_connect('localhost','root','password','mysql') | |
results = mysql.query("SHOW DATABASES") | |
results.each do |row| | |
puts row | |
system("mysqldump -u root #{row} > /root/mysql/#{row}.sql") | |
system("bzip2 -9 /root/mysql/#{row}.sql") | |
end | |
mysql.close | |
rescue Exception => error | |
puts error.message | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment