backup2qiniu 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in backup2qiniu.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,31 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ backup2qiniu (0.0.1)
5
+ backup (~> 3.0)
6
+ qiniu-rs (~> 2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ backup (3.0.24)
12
+ open4 (~> 1.3.0)
13
+ thor (~> 0.14.6)
14
+ json (1.7.3)
15
+ mime-types (1.19)
16
+ open4 (1.3.0)
17
+ qiniu-rs (2.0.1)
18
+ json (~> 1.7.3)
19
+ mime-types (~> 1.19)
20
+ rest-client (~> 1.6.7)
21
+ ruby-hmac (~> 0.4.0)
22
+ rest-client (1.6.7)
23
+ mime-types (>= 1.16)
24
+ ruby-hmac (0.4.0)
25
+ thor (0.14.6)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ backup2qiniu!
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 LI Daobing
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Backup2qiniu
2
+
3
+ 备份你的数据、文件到 [qiniutek.com](http://www.qiniutek.com/)
4
+
5
+ ## 使用方法
6
+
7
+ * 运行 gem install backup2qiniu
8
+ * 运行 backup generate:config
9
+ * 运行 backup generate:model --trigger=mysql_backup_qiniu
10
+ * 修改 ~/Backup/models/mysql_backup_qiniu.rb, 改为如下的形式
11
+
12
+ ```
13
+ require 'rubygems'
14
+ gem 'backup2qiniu'
15
+ require 'backup2qiniu'
16
+
17
+ Backup::Model.new(:mysql_backup_qiniu, 'example backup to qiniu') do
18
+ split_into_chunks_of 250
19
+
20
+ database MySQL do |db|
21
+ db.name = "for_backup"
22
+ db.username = "my_username"
23
+ db.password = "my_password"
24
+ db.host = "localhost"
25
+ db.port = 3306
26
+ db.socket = "/tmp/mysql.sock"
27
+ end
28
+
29
+ store_with Qiniu do |eb|
30
+ eb.username = 'username'
31
+ eb.password = 's3cret'
32
+ eb.bucket = 'backup'
33
+ end
34
+ end
35
+ ```
36
+
37
+ * 运行 sudo backup perform -t mysql_backup_everbox
38
+ * backup 支持备份目录,数据库等多种源,并且支持非对称密钥加密来保护数据安全,
39
+ 具体可以参考 backup 的文档: https://github.com/meskyanichi/backup
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/backup2qiniu/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["LI Daobing"]
6
+ gem.email = ["lidaobing@gmail.com"]
7
+ gem.description = %q{backup to qiniutek.com}
8
+ gem.summary = %q{backup to qiniutek.com}
9
+ gem.homepage = "https://github.com/lidaobing/backup2qiniu"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "backup2qiniu"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Backup2qiniu::VERSION
17
+ gem.add_dependency 'backup', '~> 3.0'
18
+ gem.add_dependency 'qiniu-rs', '~> 2.0'
19
+ end
@@ -0,0 +1,6 @@
1
+ module Backup
2
+ module Config
3
+ module Qiniu
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,45 @@
1
+ require 'backup/logger'
2
+ require 'qiniu/rs'
3
+
4
+ module Backup
5
+ module Storage
6
+ class Qiniu < Base
7
+
8
+ attr_accessor :username, :password
9
+ attr_accessor :bucket
10
+
11
+ def initialize(model, storage_id = nil, &block)
12
+ super(model, storage_id)
13
+
14
+ @bucket ||= 'backups'
15
+
16
+ instance_eval(&block) if block_given?
17
+ end
18
+
19
+ def path
20
+ ''
21
+ end
22
+
23
+ def transfer!
24
+ ::Qiniu::RS.establish_connection! :access_key => "3fPHl_SLkPXdioqI_A8_NGngPWVJhlDk2ktRjogH",
25
+ :secret_key => "bXTPMDJrVYRJUiSDRFtFYwycVD_mjXxYWrCYlDHy"
26
+
27
+ raise "login failed" unless ::Qiniu::RS.login!(username, password)
28
+
29
+ remote_path = remote_path_for(@package)
30
+ files_to_transfer_for(@package) do |local_file, remote_file|
31
+ Logger.message "#{storage_name} started transferring " +
32
+ "'#{ local_file }'."
33
+ remote_upload_url = ::Qiniu::RS.put_auth
34
+ key = File.join(remote_path, remote_file)
35
+ ::Qiniu::RS.upload :url => remote_upload_url,
36
+ :file => File.join(local_path, local_file),
37
+ :key => key,
38
+ :bucket => bucket,
39
+ :enable_crc32_check => true
40
+ Logger.message "file uploaded to bucket:#{bucket}, key:#{key}"
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,7 @@
1
+ require 'backup/config/qiniu'
2
+
3
+ module Backup
4
+ module Storage
5
+ autoload :Qiniu, 'backup/storage/qiniu'
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Backup2qiniu
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: backup2qiniu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - LI Daobing
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: backup
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: qiniu-rs
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.0'
46
+ description: backup to qiniutek.com
47
+ email:
48
+ - lidaobing@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - LICENSE
57
+ - README.md
58
+ - Rakefile
59
+ - backup2qiniu.gemspec
60
+ - lib/backup/config/qiniu.rb
61
+ - lib/backup/storage/qiniu.rb
62
+ - lib/backup2qiniu.rb
63
+ - lib/backup2qiniu/version.rb
64
+ homepage: https://github.com/lidaobing/backup2qiniu
65
+ licenses: []
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.23
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: backup to qiniutek.com
88
+ test_files: []
89
+ has_rdoc: