Guest User

Untitled

a guest
Dec 2nd, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require "date"
  3.  
  4. DBS = %w(database names)
  5. USER = "root" # Username with rights to all those databases
  6. PW = "" # Password for that username
  7.  
  8. today_s = Date.today().to_s
  9. yesterday_s = (Date.today()-(2)).to_s
  10.  
  11. DBS.each do |db|
  12. system "/usr/bin/mysqldump --user=#{USER} --password=#{PW} -t --opt -icC #{db} > ~/home/dbs/#{today_s}-#{db}.sql"
  13. if File.exist?("/home/dbs/#{yesterday_s}-#{db}.sql")
  14. File.unlink("/home/dbs/#{yesterday_s}-#{db}.sql")
  15. end
  16. end
Add Comment
Please, Sign In to add comment