Rake任务备份和恢复数据库 [英] Rake task to backup and restore database
本文介绍了Rake任务备份和恢复数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Rails项目,有时我在家里,有时在工作。在我的开发过程中,我将数据添加到数据库,我真的需要一种方法来同步数据库在家里和工作。
I am working on a Rails project, and sometimes I program at home and sometimes at work. In my development process, I add data to the database, and I really need a way to synchronize the databases at home and work.
我在考虑一个Rake任务
I am thinking about a Rake task to backup/restore the whole database in a Rails app.
Is there anyway to do that?
推荐答案
在Rails应用程序中备份/恢复整个数据库。写一个rake任务:
write a rake task:
namespace :db do
task :backup do
system "mysqldump --opt --user=root --password rose userdetails> xyz.sql"
end
task :restore do
system "mysqldump --user=root --password < xyz.sql"
end
end
由 rake db:backup
你会得到你可以提交到你的git / svn的sql,一旦你回家工作恢复pull并运行 rake db:restore
By the rake db:backup
you will get the sql that you can commit to your git/svn and once you work from home to restore pull it and run rake db:restore
这篇关于Rake任务备份和恢复数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文