mongo_sync 0.1.1 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +128 -10
- data/lib/mongo_sync/version.rb +1 -1
- data/lib/tasks/mongo_sync.rake +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8465776703c0c1d48a595cb27c8e5bce56fb0c7
|
4
|
+
data.tar.gz: edf1461081606f6a6573fbdaef2a883ee34804c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e1338e1f0cf1b6bb3c15dbf536a40762819970537947eb152f3507f58abde773e4870141d54f67200a3ff627f5c975ae25c70b92a1f187e067b081028ee59fc
|
7
|
+
data.tar.gz: f25459fd62dc93b501fcfe178585e5c2ad12d13f551d81c727d2513f7d690c8397964ca42ae3c1be5a691d3a58af21f0d24ebb96c588b23645857e5f5f1a6fab
|
data/README.md
CHANGED
@@ -1,30 +1,148 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
MongoSync
|
2
|
+
=========
|
3
|
+
|
4
|
+
> Sync Remote and Local MongoDB Databases in Ruby! Works with MongoHQ/Compose, MongoLab and other Heroku-hosted MongoDBs too!
|
5
|
+
|
6
|
+
Based on my [mongo-sync](https://github.com/sheharyarn/mongo-sync) shell script.
|
3
7
|
|
4
|
-
> Sync Remote and Local MongoDB Databases in Ruby!
|
5
8
|
|
6
9
|
## Installation
|
7
10
|
|
8
11
|
Add this line to your application's Gemfile:
|
9
12
|
|
13
|
+
```ruby
|
14
|
+
group :development do
|
10
15
|
gem 'mongo_sync'
|
16
|
+
end
|
17
|
+
```
|
11
18
|
|
12
19
|
And then execute:
|
13
20
|
|
14
|
-
|
21
|
+
```bash
|
22
|
+
$ bundle
|
23
|
+
```
|
15
24
|
|
16
25
|
Or install it yourself as:
|
17
26
|
|
18
|
-
|
27
|
+
```bash
|
28
|
+
$ gem install mongo_sync
|
29
|
+
```
|
30
|
+
|
19
31
|
|
20
32
|
## Usage
|
21
33
|
|
22
|
-
|
34
|
+
### Rails
|
35
|
+
|
36
|
+
In Rails, run this generator to set up a `mongo_sync.yml` configuration template:
|
37
|
+
|
38
|
+
```bash
|
39
|
+
rails g mongo_sync:config
|
40
|
+
```
|
41
|
+
|
42
|
+
Now edit the newly created `config/mongo_sync.yml`, putting in details of your remote and local DBs:
|
43
|
+
|
44
|
+
```yaml
|
45
|
+
local:
|
46
|
+
db: 'local_db_name'
|
47
|
+
|
48
|
+
remote:
|
49
|
+
db: 'remote_db_name'
|
50
|
+
host:
|
51
|
+
url: 'some.remoteurl.com'
|
52
|
+
port: 27017
|
53
|
+
access:
|
54
|
+
username: 'remote_mongo_user'
|
55
|
+
password: 'remote_mongo_pass'
|
56
|
+
|
57
|
+
# For Heroku MongoDB URLs, here's the legend:
|
58
|
+
# mongodb://username:password@hosturl.com:port/db_name
|
59
|
+
|
60
|
+
# All fields are required
|
61
|
+
```
|
62
|
+
|
63
|
+
Now, to start syncing, use these rake tasks:
|
64
|
+
|
65
|
+
```sh
|
66
|
+
rake mongo_sync:push # Push DB to Remote
|
67
|
+
rake mongo_sync:pull # Pull DB to Local
|
68
|
+
```
|
69
|
+
|
70
|
+
### Non-Rails
|
71
|
+
|
72
|
+
1. Create a `mongo_sync.yml` in your project.
|
73
|
+
2. In your project, add this:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
require 'rake'
|
77
|
+
require 'mongo_sync'
|
78
|
+
load 'tasks/mongo_sync.rake'
|
79
|
+
```
|
80
|
+
|
81
|
+
3. Pass the path of your config file in the tasks:
|
82
|
+
|
83
|
+
```sh
|
84
|
+
rake mongo_sync:push['path/to/mongo_sync.yml']
|
85
|
+
```
|
86
|
+
|
87
|
+
### Console / Command-line
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
require 'mongo_sync'
|
91
|
+
|
92
|
+
# Looks for config/mongo_sync.yml - Rails only
|
93
|
+
MongoSync.pull
|
94
|
+
|
95
|
+
# You can pass path of your config file as well
|
96
|
+
MongoSync.push "path/to/mongo_sync.yml"
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
## Notes
|
101
|
+
|
102
|
+
- Pushing/Pulling overwrites the Target DB
|
103
|
+
- It's a good idea to keep your `mongo_sync.yml` in `.gitignore` or load the values from the `ENV`
|
104
|
+
|
105
|
+
|
106
|
+
## TODO
|
107
|
+
|
108
|
+
- Add more options and ways to enter DB details in `mongo_sync.yml`
|
109
|
+
- Add a `backup` command/task and an `auto-backup` feature
|
110
|
+
- Write Tests
|
111
|
+
- Add a `no-overwrite` feature, so that it doesn't drop the target DB before restoring it, and _actually_ tries to sync it
|
112
|
+
|
23
113
|
|
24
114
|
## Contributing
|
25
115
|
|
26
|
-
1. Fork it
|
27
|
-
2. Create your feature branch (`git checkout -b my-
|
116
|
+
1. [Fork it](https://github.com/sheharyarn/mongo-sync-ruby/fork)
|
117
|
+
2. Create your feature/fix branch (`git checkout -b feature/my-feature`)
|
28
118
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
29
|
-
4. Push to the branch (`git push origin my-
|
30
|
-
5. Create new Pull Request
|
119
|
+
4. Push to the branch (`git push origin feature/my-feature`)
|
120
|
+
5. Create a new Pull Request
|
121
|
+
|
122
|
+
|
123
|
+
## License
|
124
|
+
|
125
|
+
Copyright (c) 2015 Sheharyar Naseer
|
126
|
+
|
127
|
+
MIT License
|
128
|
+
|
129
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
130
|
+
a copy of this software and associated documentation files (the
|
131
|
+
"Software"), to deal in the Software without restriction, including
|
132
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
133
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
134
|
+
permit persons to whom the Software is furnished to do so, subject to
|
135
|
+
the following conditions:
|
136
|
+
|
137
|
+
The above copyright notice and this permission notice shall be
|
138
|
+
included in all copies or substantial portions of the Software.
|
139
|
+
|
140
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
141
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
142
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
143
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
144
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
145
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
146
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
147
|
+
|
148
|
+
|
data/lib/mongo_sync/version.rb
CHANGED
data/lib/tasks/mongo_sync.rake
CHANGED