Created
September 17, 2013 08:11
-
-
Save guange2015/6591403 to your computer and use it in GitHub Desktop.
mysql备份
This file contains hidden or 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/env ruby | |
| require 'date' | |
| DBS = %w( depot_development ) | |
| USER = "root" # Username with rights to all those databases, might be root | |
| PW = "123456" # Password for that username | |
| today_s = Date.today().to_s | |
| yesterday_s = (Date.today()-(2)).to_s | |
| DBS.each do |db| | |
| system "mysqldump --user=#{USER} --password=#{PW} --add-drop-database --opt -icC #{db} > /tmp/#{today_s}-#{db}.sql" | |
| if File.exist?("/tmp/#{yesterday_s}-#{db}.sql") | |
| File.unlink("/tmp/#{yesterday_s}-#{db}.sql") | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment