Guest User

Untitled

a guest
Apr 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #!/usr/bin/ruby
  2. require 'ftools'
  3.  
  4. # (db names and password changed in this paste to protect the (not so)innocent)
  5.  
  6. # get the next directory
  7. ts = Time.now.to_s
  8. backupdir = "#{ENV['HOME']}/backups/db"
  9.  
  10. # for each production database
  11. %w(prod_1 prod_2 prod_3).each do |db|
  12. # do an sql dump to our backup directory
  13. `mysqldump -u backup --password=xxx #{db} > #{backupdir}/#{db}.sql`
  14. end
  15.  
  16. # store the changes as a commit in the backups/db git repo
  17. `cd #{backupdir} && git add . && git commit -m "data backup #{ts}" && cd -`
Add Comment
Please, Sign In to add comment