cloudant_backup 0.0.1 → 0.0.2
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/.travis.yml +6 -0
- data/README.md +6 -6
- data/lib/cloudant_backup/backup.rb +15 -1
- data/lib/cloudant_backup/version.rb +1 -1
- data/spec/lib/cloudant_backup_spec.rb +4 -4
- metadata +35 -28
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
Most simple case
|
23
|
+
Most simple case. Replicate your production db to an automatically
|
24
24
|
named backup db on cloudant:
|
25
25
|
|
26
26
|
```ruby
|
@@ -29,7 +29,7 @@ named backup db on cloudant:
|
|
29
29
|
cb.password = 'password'
|
30
30
|
cb.source = 'my_production_db'
|
31
31
|
|
32
|
-
cb.
|
32
|
+
cb.backup # Backup my_production_db to my_production_db_backup_2013_09_10
|
33
33
|
```
|
34
34
|
|
35
35
|
Create only one db per month (you can still update it daily):
|
@@ -39,7 +39,7 @@ Create only one db per month (you can still update it daily):
|
|
39
39
|
[...]
|
40
40
|
cb.date_pattern = '%Y_%m' # Any strftime string works
|
41
41
|
|
42
|
-
cb.
|
42
|
+
cb.backup
|
43
43
|
```
|
44
44
|
|
45
45
|
Choose the target db name yourself:
|
@@ -49,7 +49,7 @@ Choose the target db name yourself:
|
|
49
49
|
[...]
|
50
50
|
cb.target = 'custom_target_db_name'
|
51
51
|
|
52
|
-
cb.
|
52
|
+
cb.backup
|
53
53
|
```
|
54
54
|
|
55
55
|
Use another user instead of your cloudant main user:
|
@@ -60,7 +60,7 @@ Use another user instead of your cloudant main user:
|
|
60
60
|
cb.user = 'generated_api_key'
|
61
61
|
cb.cloudant_host = 'mainuser'
|
62
62
|
|
63
|
-
cb.
|
63
|
+
cb.backup
|
64
64
|
```
|
65
65
|
|
66
66
|
Don't use cloudant at all, just copy one couchdb over to another:
|
@@ -70,7 +70,7 @@ Don't use cloudant at all, just copy one couchdb over to another:
|
|
70
70
|
[...]
|
71
71
|
cb.host = 'my-couchdb-instance.com'
|
72
72
|
|
73
|
-
cb.
|
73
|
+
cb.backup
|
74
74
|
```
|
75
75
|
|
76
76
|
Thank you for your business!
|
@@ -28,6 +28,16 @@ class CloudantBackup
|
|
28
28
|
make_request(:post, "_replicate", data)
|
29
29
|
end
|
30
30
|
|
31
|
+
def host=(host)
|
32
|
+
parts = host.split("://")
|
33
|
+
if parts.length ==2
|
34
|
+
@protocol, @host = host.split("://")
|
35
|
+
else
|
36
|
+
@protocol = "http"
|
37
|
+
@host = host
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
31
41
|
private
|
32
42
|
|
33
43
|
def date_string
|
@@ -57,7 +67,11 @@ class CloudantBackup
|
|
57
67
|
end
|
58
68
|
|
59
69
|
def db_url(name)
|
60
|
-
"
|
70
|
+
"#{protocol}://#{user}:#{password}@#{host}/#{name}"
|
71
|
+
end
|
72
|
+
|
73
|
+
def protocol
|
74
|
+
@protocol || "https"
|
61
75
|
end
|
62
76
|
|
63
77
|
def make_request(method, url, data = nil)
|
@@ -67,7 +67,7 @@ describe CloudantBackup do
|
|
67
67
|
it "creates the backup db" do
|
68
68
|
cb.host = 'my-couchdb.com'
|
69
69
|
cb.target = 'custom-name'
|
70
|
-
url = "
|
70
|
+
url = "http://backup-user:password@my-couchdb.com/custom-name"
|
71
71
|
RestClient.should_receive(:put).with(url, options)
|
72
72
|
cb.create_target_db
|
73
73
|
end
|
@@ -75,9 +75,9 @@ describe CloudantBackup do
|
|
75
75
|
it "triggers the replication" do
|
76
76
|
cb.target = 'custom-name'
|
77
77
|
cb.host = 'my-couchdb.com'
|
78
|
-
url = "
|
79
|
-
source_db = "
|
80
|
-
target_db = "
|
78
|
+
url = "http://backup-user:password@my-couchdb.com/_replicate"
|
79
|
+
source_db = "http://backup-user:password@my-couchdb.com/production-db"
|
80
|
+
target_db = "http://backup-user:password@my-couchdb.com/custom-name"
|
81
81
|
data = {
|
82
82
|
source: source_db,
|
83
83
|
target: target_db
|
metadata
CHANGED
@@ -2,110 +2,110 @@
|
|
2
2
|
name: cloudant_backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jannis Hermanns
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
|
17
|
-
|
16
|
+
type: :development
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '1.3'
|
22
|
-
requirement: !ruby/object:Gem::Requirement
|
23
22
|
none: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.3'
|
28
|
-
|
28
|
+
none: false
|
29
29
|
prerelease: false
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
|
-
|
33
|
-
|
32
|
+
type: :development
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
34
|
requirements:
|
35
35
|
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: '0'
|
38
|
-
requirement: !ruby/object:Gem::Requirement
|
39
38
|
none: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
|
-
|
44
|
+
none: false
|
45
45
|
prerelease: false
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: rest-client
|
48
|
-
|
49
|
-
|
48
|
+
type: :runtime
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - ! '>='
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
55
54
|
none: false
|
55
|
+
version_requirements: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - ! '>='
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
|
-
|
60
|
+
none: false
|
61
61
|
prerelease: false
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: guard-rspec
|
64
|
-
|
65
|
-
|
64
|
+
type: :runtime
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - ! '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
71
70
|
none: false
|
71
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
|
-
|
76
|
+
none: false
|
77
77
|
prerelease: false
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: guard-bundler
|
80
|
-
|
81
|
-
|
80
|
+
type: :runtime
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - ! '>='
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: '0'
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
86
|
none: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - ! '>='
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
|
-
|
92
|
+
none: false
|
93
93
|
prerelease: false
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: guard
|
96
|
-
|
97
|
-
|
96
|
+
type: :runtime
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
99
|
- - ! '>='
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
|
-
requirement: !ruby/object:Gem::Requirement
|
103
102
|
none: false
|
103
|
+
version_requirements: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
105
|
- - ! '>='
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
|
-
|
108
|
+
none: false
|
109
109
|
prerelease: false
|
110
110
|
description: Makes a backup of a cloudant db
|
111
111
|
email:
|
@@ -115,6 +115,7 @@ extensions: []
|
|
115
115
|
extra_rdoc_files: []
|
116
116
|
files:
|
117
117
|
- .gitignore
|
118
|
+
- .travis.yml
|
118
119
|
- Gemfile
|
119
120
|
- Guardfile
|
120
121
|
- LICENSE.txt
|
@@ -135,17 +136,23 @@ rdoc_options: []
|
|
135
136
|
require_paths:
|
136
137
|
- lib
|
137
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
-
none: false
|
139
139
|
requirements:
|
140
140
|
- - ! '>='
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
+
segments:
|
143
|
+
- 0
|
144
|
+
hash: 3180739372986018778
|
142
145
|
version: '0'
|
143
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
146
|
none: false
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
148
|
requirements:
|
146
149
|
- - ! '>='
|
147
150
|
- !ruby/object:Gem::Version
|
151
|
+
segments:
|
152
|
+
- 0
|
153
|
+
hash: 3180739372986018778
|
148
154
|
version: '0'
|
155
|
+
none: false
|
149
156
|
requirements: []
|
150
157
|
rubyforge_project:
|
151
158
|
rubygems_version: 1.8.25
|