mongo-db-utils 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -0
- data/lib/mongo-db-utils/s3.rb +16 -9
- data/lib/mongo-db-utils/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -25,6 +25,11 @@ And then execute:
|
|
25
25
|
|
26
26
|
$ mongo-db-utils console
|
27
27
|
|
28
|
+
|
29
|
+
## Limitatons
|
30
|
+
|
31
|
+
Only works on ruby 1.9.3 (to_yaml is throwing an error in earlier versions)
|
32
|
+
|
28
33
|
## Usage
|
29
34
|
Once you launch the console it'll provide you with a set of options - pretty self explanatory.
|
30
35
|
When it does backups it stores them in ````~/.mongo-db-utils/backups/````. The naming convention is ````${server}_${port}/${database_name}/${timestamp}/db````
|
data/lib/mongo-db-utils/s3.rb
CHANGED
@@ -2,17 +2,24 @@ require 'aws/s3'
|
|
2
2
|
|
3
3
|
module MongoDbUtils
|
4
4
|
|
5
|
-
|
5
|
+
class S3
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
def self.put_file(file, name, bucket_name, access_key_id, secret_access_key)
|
8
|
+
puts "putting file to Amazon S3"
|
9
|
+
AWS::S3::Base.establish_connection!(
|
10
|
+
:access_key_id => access_key_id,
|
11
|
+
:secret_access_key => secret_access_key
|
12
|
+
)
|
13
13
|
|
14
|
-
|
15
|
-
AWS::S3::
|
14
|
+
begin
|
15
|
+
AWS::S3::Bucket.find(bucket_name)
|
16
|
+
rescue AWS::S3::NoSuchBucket
|
17
|
+
AWS::S3::Bucket.create(bucket_name)
|
18
|
+
rescue AWS::S3::AllAccessDisabled
|
19
|
+
puts "Error:: You cannot access this bucket: #{bucket_name}"
|
20
|
+
return
|
16
21
|
end
|
22
|
+
AWS::S3::S3Object.store(name, open(file), bucket_name)
|
17
23
|
end
|
24
|
+
end
|
18
25
|
end
|