Skip to content

Instantly share code, notes, and snippets.

@jesseadams
Created July 16, 2010 09:55
Show Gist options
  • Save jesseadams/478194 to your computer and use it in GitHub Desktop.
Save jesseadams/478194 to your computer and use it in GitHub Desktop.
#!/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