4

在rails中用backup数据备份-dropbox篇

 3 years ago
source link: http://blog.grayson.org.cn/blog/2014/05/01/rails-instance-backup-dot-gem-data-backup-2
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

在rails中用backup数据备份-dropbox篇

May 01, 2014

###1.申请dropbox的api_key与api_secret

打开https://www.dropbox.com/developers/apps申请

####第一步

点击右上角的”Create app“

####第二步

点击右下角的”Create app“

####第三步

####第四步

复制App key与App secret 到下面的置文件中

打开config/backup/models/my_backup.rb 添加dropbox配置

```ruby config/backup/models/my_backup.rb Model.new(:my_backup, 'Description for my_backup') do ... ...

## # Dropbox [Storage] # # Your initial backup must be performed manually to authorize # this machine with your Dropbox account. This authorized session # will be stored in cache_path and used for subsequent backups. # store_with Dropbox do |db| db.api_key = "my_api_key" #把App key复制到这里 db.api_secret = "my_api_secret" #把App secret复制到这里 # Sets the path where the cached authorized session will be stored. # Relative paths will be relative to ~/Backup, unless the --root-path # is set on the command line or within your configuration file. db.cache_path = ".cache" # :app_folder (default) or :dropbox db.access_type = :app_folder db.path = "backups" db.keep = 25 end

... ... end

####第五步

运行备份同步脚本

cd rails_app $ backup perform -t my_backup -c 'config/backup/my_config.rb'


####第六步

oauth授权与运行成功

https://www.dropbox.com/1/oauth/authorize?oauth_token=FepGwVGFYvMAgtvj
用到浏览器打开

![]( /images/uploads/rails-instance-backup-dot-gem-data-backup/open_browser1.jpg)

点击”允许“

![]( /images/uploads/rails-instance-backup-dot-gem-data-backup/open_browser2.jpg)

授权成功

![]( /images/uploads/rails-instance-backup-dot-gem-data-backup/terminal_enter.jpg)

回到命令行,按”回车“键 继续!

![]( /images/uploads/rails-instance-backup-dot-gem-data-backup/terminal_success.png)

搞定,查看下!dorpbox目录,已经同步好了!

[~/Dropbox/应用/backuprb] $ tree . ├── Icon\r └── backups └── my_backup └── 2014.05.03.16.09.25 └── my_backup.tar

3 directories, 2 files









ref:

* [dropbox配置](http://meskyanichi.github.io/backup/v4/storage-dropbox/)
* [http://meskyanichi.github.io/backup/v4](http://meskyanichi.github.io/backup/v4/)

此文章 短链接: http://dlj.bz/JrhS7e

Posted by grayson May 01, 2014 ruby rails backup data mongodb dropbox gem skill

« 在rails中用backup数据备份-备份篇

Ruby's Array and Array.wrap的区别»


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK