example_backup.rb 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # This file contains an example template for using the Backup gem for backing up your Huginn installation to S3.
  2. # In your crontab do something like:
  3. # 0 0,12 * * * /bin/bash -l -c "RAILS_ENV=production backup perform -t huginn_backup --config_file /home/you/huginn_backup.rb" 2>&1 >> /home/you/huginn_backup_log.txt
  4. # In backups.password on your server:
  5. # some password
  6. # In huginn_backup.rb on your server put an edited version of the following file. REMEMBER TO EDIT THE FILE!
  7. # You'll also need to install the backup gem on your server, as well as the net-ssh, excon, net-scp, and fog gems.
  8. Backup::Model.new(:huginn_backup, 'The Huginn backup configuration') do
  9. split_into_chunks_of 4000
  10. database MySQL do |database|
  11. database.name = "your-database-name"
  12. database.username = "your-database-username"
  13. database.password = "your-database-password"
  14. database.host = "your-database-host"
  15. database.port = "your-database-port"
  16. database.socket = "your-database-socket"
  17. database.additional_options = ['--single-transaction', '--quick', '--hex-blob', '--add-drop-table']
  18. end
  19. encrypt_with OpenSSL do |encryption|
  20. encryption.password_file = "/home/you/backups.password"
  21. encryption.base64 = true
  22. encryption.salt = true
  23. end
  24. compress_with Gzip do |compression|
  25. compression.level = 8
  26. end
  27. store_with S3 do |s3|
  28. s3.access_key_id = 'YOUR_AWS_ACCESS_KEY'
  29. s3.secret_access_key = 'YOUR_AWS_SECRET'
  30. s3.region = 'us-east-1'
  31. s3.bucket = 'my-huginn-backups'
  32. s3.keep = 20
  33. end
  34. notify_by Mail do |mail|
  35. mail.on_success = false
  36. mail.on_warning = true
  37. mail.on_failure = true
  38. mail.from = 'you@example.com'
  39. mail.to = 'you@example.com'
  40. mail.address = 'smtp.gmail.com'
  41. mail.domain = "example.com"
  42. mail.user_name = 'you@example.com'
  43. mail.password = 'password'
  44. mail.port = 587
  45. mail.authentication = "plain"
  46. mail.encryption = :starttls
  47. end
  48. end