heroku-mongo-backup 0.3.2 → 0.3.6
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/lib/heroku_mongo_backup.rb +41 -5
- metadata +13 -12
data/lib/heroku_mongo_backup.rb
CHANGED
@@ -7,6 +7,7 @@ require 'zlib'
|
|
7
7
|
require 'uri'
|
8
8
|
require 'yaml'
|
9
9
|
require 'rubygems'
|
10
|
+
require 'net/ftp'
|
10
11
|
|
11
12
|
module HerokuMongoBackup
|
12
13
|
require 'heroku_mongo_backup/railtie' if defined?(Rails)
|
@@ -79,7 +80,25 @@ module HerokuMongoBackup
|
|
79
80
|
@db = connection.db(uri.path.gsub(/^\//, ''))
|
80
81
|
@db.authenticate(uri.user, uri.password) if uri.user
|
81
82
|
end
|
82
|
-
|
83
|
+
|
84
|
+
def ftp_connect
|
85
|
+
@ftp = Net::FTP.new(ENV['FTP_HOST'])
|
86
|
+
@ftp.passive = true
|
87
|
+
@ftp.login(ENV['FTP_USERNAME'], ENV['FTP_PASSWORD'])
|
88
|
+
end
|
89
|
+
|
90
|
+
def ftp_upload
|
91
|
+
@ftp.putbinaryfile(@file_name)
|
92
|
+
end
|
93
|
+
|
94
|
+
def ftp_download
|
95
|
+
open(@file_name, 'w') do |file|
|
96
|
+
file_content = @ftp.getbinaryfile(@file_name)
|
97
|
+
file.binmode
|
98
|
+
file.write file_content
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
83
102
|
def s3_connect
|
84
103
|
bucket = ENV['S3_BACKUPS_BUCKET']
|
85
104
|
if bucket.nil?
|
@@ -136,20 +155,37 @@ module HerokuMongoBackup
|
|
136
155
|
puts "Using databased: #{@url}"
|
137
156
|
|
138
157
|
self.db_connect
|
139
|
-
|
158
|
+
|
159
|
+
if ENV['UPLOAD_TYPE'] == 'ftp'
|
160
|
+
self.ftp_connect
|
161
|
+
else
|
162
|
+
self.s3_connect
|
163
|
+
end
|
140
164
|
end
|
141
165
|
|
142
166
|
def backup
|
143
167
|
self.chdir
|
144
168
|
self.store
|
145
|
-
self.s3_upload
|
146
|
-
end
|
147
169
|
|
170
|
+
if ENV['UPLOAD_TYPE'] == 'ftp'
|
171
|
+
self.ftp_upload
|
172
|
+
@ftp.close
|
173
|
+
else
|
174
|
+
self.s3_upload
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
148
178
|
def restore file_name
|
149
179
|
@file_name = file_name
|
150
180
|
|
151
181
|
self.chdir
|
152
|
-
|
182
|
+
|
183
|
+
if ENV['UPLOAD_TYPE'] == 'ftp'
|
184
|
+
self.ftp_download
|
185
|
+
@ftp.close
|
186
|
+
else
|
187
|
+
self.s3_download
|
188
|
+
end
|
153
189
|
self.load
|
154
190
|
end
|
155
191
|
end
|
metadata
CHANGED
@@ -1,19 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku-mongo-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Alex
|
8
|
+
- Alex Kravets
|
9
|
+
- matyi
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2012-
|
13
|
+
date: 2012-05-01 00:00:00.000000000Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: rspec
|
16
|
-
requirement: &
|
17
|
+
requirement: &70361846274660 !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
@@ -21,10 +22,10 @@ dependencies:
|
|
21
22
|
version: '0'
|
22
23
|
type: :development
|
23
24
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
+
version_requirements: *70361846274660
|
25
26
|
- !ruby/object:Gem::Dependency
|
26
27
|
name: mocha
|
27
|
-
requirement: &
|
28
|
+
requirement: &70361846273820 !ruby/object:Gem::Requirement
|
28
29
|
none: false
|
29
30
|
requirements:
|
30
31
|
- - ! '>='
|
@@ -32,10 +33,10 @@ dependencies:
|
|
32
33
|
version: '0'
|
33
34
|
type: :development
|
34
35
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
+
version_requirements: *70361846273820
|
36
37
|
- !ruby/object:Gem::Dependency
|
37
38
|
name: crack
|
38
|
-
requirement: &
|
39
|
+
requirement: &70361846272260 !ruby/object:Gem::Requirement
|
39
40
|
none: false
|
40
41
|
requirements:
|
41
42
|
- - ! '>='
|
@@ -43,9 +44,9 @@ dependencies:
|
|
43
44
|
version: '0'
|
44
45
|
type: :development
|
45
46
|
prerelease: false
|
46
|
-
version_requirements: *
|
47
|
-
description: Rake task for backing up mongo database on heroku and push it to S3
|
48
|
-
Library can be used as rake task or be easily integrated into daily cron job.
|
47
|
+
version_requirements: *70361846272260
|
48
|
+
description: Rake task for backing up mongo database on heroku and push it to S3 or
|
49
|
+
FTP. Library can be used as rake task or be easily integrated into daily cron job.
|
49
50
|
email: santyor@gmail.com
|
50
51
|
executables: []
|
51
52
|
extensions: []
|
@@ -79,5 +80,5 @@ rubygems_version: 1.8.6
|
|
79
80
|
signing_key:
|
80
81
|
specification_version: 3
|
81
82
|
summary: Rake task backups mongo database on Heroku and push gzipped file to Amazon
|
82
|
-
S3.
|
83
|
+
S3 or FTP.
|
83
84
|
test_files: []
|