heroku-mongo-backup 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/heroku-mongo-backup.gemspec +1 -1
- data/lib/s3_helpers.rb +6 -14
- metadata +2 -2
data/README.md
CHANGED
@@ -64,3 +64,4 @@ For Rails 2 add this to your Rakefile to import rake tasks:
|
|
64
64
|
3. [stefl - stef.io](http://stef.io "Stef Lewandowski") - Rails is not required for production
|
65
65
|
4. [moonhouse - moonhouse.se](http://www.moonhouse.se/ "David Hall") - default config improvement
|
66
66
|
5. [wolfpakz](https://github.com/wolfpakz "Dan Porter") - Rails2 support
|
67
|
+
6. [solacreative](http://sola-la.com/creative "Taro Murao") - Max backups feature for aws/s3 and s3 gems
|
data/heroku-mongo-backup.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'heroku-mongo-backup'
|
3
|
-
s.version = '0.4.
|
3
|
+
s.version = '0.4.3'
|
4
4
|
s.summary = 'Rake task backups mongo database on Heroku and push gzipped file to Amazon S3 or FTP.'
|
5
5
|
s.description = 'Rake task for backing up mongo database on heroku and push it to S3 or FTP. Library can be used as rake task or be easily integrated into daily cron job.'
|
6
6
|
|
data/lib/s3_helpers.rb
CHANGED
@@ -39,7 +39,9 @@ if defined?(S3)
|
|
39
39
|
return content
|
40
40
|
end
|
41
41
|
|
42
|
-
def HerokuMongoBackup::remove_old_backup_files(files_number_to_leave)
|
42
|
+
def HerokuMongoBackup::remove_old_backup_files(bucket, files_number_to_leave)
|
43
|
+
excess = ( object_keys = bucket.objects.find_all(:prefix => "backups/").map { |o| o.key }.sort ).count - files_number_to_leave
|
44
|
+
(0..excess-1).each { |i| bucket.objects.find(object_keys[i]).destroy } if excess > 0
|
43
45
|
end
|
44
46
|
|
45
47
|
end
|
@@ -75,19 +77,9 @@ if defined?(AWS)
|
|
75
77
|
return content
|
76
78
|
end
|
77
79
|
|
78
|
-
def HerokuMongoBackup::remove_old_backup_files(
|
79
|
-
|
80
|
-
|
81
|
-
object_keys = []
|
82
|
-
bucket.objects.each { |o| object_keys << o.key }
|
83
|
-
|
84
|
-
object_keys = object_keys.sort
|
85
|
-
|
86
|
-
excess = object_keys.count - files_number_to_leave
|
87
|
-
|
88
|
-
if excess > 0
|
89
|
-
(0..excess-1).each { |i| S3Object.find(object_keys[i], bucket_name).delete }
|
90
|
-
end
|
80
|
+
def HerokuMongoBackup::remove_old_backup_files(bucket, files_number_to_leave)
|
81
|
+
excess = ( object_keys = AWS::S3::Bucket.find(bucket).objects(:prefix => 'backups/').map { |o| o.key }.sort ).count - files_number_to_leave
|
82
|
+
(0..excess-1).each { |i| AWS::S3::S3Object.find(object_keys[i], bucket).delete } if excess > 0
|
91
83
|
end
|
92
84
|
|
93
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku-mongo-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2012-10-
|
16
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: mongo
|