Guest User

Untitled

a guest
Oct 12th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. # encoding: utf-8
  2. #
  3. ##
  4. # Backup Generated: sample_backup
  5. # Once configured, you can run the backup with the following command:
  6. #
  7. # RAILS_ENV=production backup perform --trigger daily_backup -c ./config/backup.rb
  8. #
  9. #
  10.  
  11. require 'yaml'
  12.  
  13. RAILS_ROOT = File.join(File.dirname(__FILE__), "..")
  14. DATABASE_YML = File.join(RAILS_ROOT, "config", "database.yml")
  15. RAILS_ENV = ENV['RAILS_ENV'] || 'development'
  16. $config = YAML.load_file(DATABASE_YML)
  17.  
  18. Backup::Model.new(:daily_backup, 'db and log to sftp') do
  19. split_into_chunks_of 50
  20.  
  21. database MySQL do |db|
  22. db.name = $config[RAILS_ENV]["database"]
  23. db.username = $config[RAILS_ENV]["username"]
  24. db.password = $config[RAILS_ENV]["password"]
  25. db.host = $config[RAILS_ENV]["host"]
  26. db.port = $config[RAILS_ENV]["port"]
  27. db.socket = $config[RAILS_ENV]["socket"]
  28. db.additional_options = ["--quick", "--single-transaction"]
  29. end
  30.  
  31. archive :logs do |archive|
  32. archive.add "#{RAILS_ROOT}/log/production.log"
  33. end
  34.  
  35. store_with SFTP do |server|
  36. server.username = 'sftp_user'
  37. server.password = 'sftp_pwd'
  38. server.ip = 'sftp_ip'
  39. server.port = 22
  40. server.path = 'backups/'
  41. server.keep = 5
  42. end
  43.  
  44. compress_with Gzip do |compression|
  45. compression.level = 6
  46. end
  47.  
  48. notify_by Mail do |mail|
  49. mail.on_success = true
  50. mail.on_warning = true
  51. mail.on_failure = true
  52. mail.from = 'notify_user@gmail.com'
  53. mail.to = 'receive@gmail.com'
  54. mail.address = 'smtp.gmail.com'
  55. mail.port = 587
  56. mail.domain = 'agideo.com'
  57. mail.user_name = 'notify_user@gmail.com'
  58. mail.password = 'notify_pwd'
  59. mail.authentication = 'plain'
  60. mail.enable_starttls_auto = true
  61. end
  62. end
Add Comment
Please, Sign In to add comment