How to take Auto backup of Mysql Database in Rails 4

…衆ロ難τιáo~ 提交于 2019-12-12 03:39:52

问题


I am using Rails 4 with Mysql2 as a database in Windows.I want to take auto backup of my database every second. So that there should be folder generated at every second in the path which i specify and also an email must be sent along with database as an attachment.I used whenever gem for this purpose but i am unable to get what i must write in my schedule.rb file.

schedule.rb file

every :day, :at => '12:05am' do
  rake 'task_namespace:autobackup' , :environment => 'development',   :output => 'log/autobackup_mail.log'
  # rake 'task_namespace:autobackup_with_mail' , :environment => 'development',   :output => 'log/autobackup.log'
end

回答1:


you can use the gem Backup.

Backup is a system utility for Linux and Mac OS X, distributed as a RubyGem, that allows you to easily perform backup operations. It provides an elegant DSL in Ruby for modeling your backups. Backup has built-in support for various databases, storage protocols/services, syncers, compressors, encryptors and notifiers which you can mix and match. It was built with modularity, extensibility and simplicity in mind.

you can visit: http://backup.github.io/backup/v4/database-mysql/

Backup allows you to model your backup jobs using a Ruby DSL:

Backup::Model.new(:my_backup, 'Description for my_backup') do
  # ... Model Components ...
end

The :my_backup symbol is the model’s trigger and used to perform the job:

$ backup perform --trigger my_backup

it also support PostgreSQL, MongoDB, Redis, Riak, SQLite



来源:https://stackoverflow.com/questions/43320451/how-to-take-auto-backup-of-mysql-database-in-rails-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!