ey_db_backup 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,10 +1,11 @@
1
1
  == Engine Yard Database Backup
2
2
 
3
- Engine Yard Database Backup is used to backup the latest database backup from Amazon's S3 service.
3
+ Engine Yard Database Backup is used to backup the latest database backup from Amazon's S3 service.
4
4
  This gem downloads the latest file in the bucket you specify in your AWS S3 account.
5
5
  This backup utility is to make sure there is a recent backup of the database incase Amazon's S3 service goes down and you need access to your data.
6
6
 
7
7
  == Setting up and using the Engine Yard Database Backup gem
8
+
8
9
  1. <tt>gem install ey_db_backup</tt>
9
10
  2. Create the directory <tt>config</tt> within the local directory you are running the gem in.
10
11
  3. Create a YAML file <tt>config.yml</tt> structured as below:
@@ -12,8 +13,12 @@ This backup utility is to make sure there is a recent backup of the database inc
12
13
  secret_access_key: "put your secret access key here"
13
14
  bucket_name: "put the bucket name here"
14
15
  export_path: "put the location you want to export the file to here (e.g. documents/db_exports/)"
16
+ environment: "put which environment you want backed up in Engine Yard (e.g. Production)"
17
+ databases:
18
+ - "list all databases here (e.g. apple)"
19
+ - "(e.g. orange)"
15
20
  4. Simply run <tt>ey_db_backup run_export</tt> to download the latest file in the bucket you specified to the directory you specified.
16
-
21
+
17
22
  == Configuring Engine Yard Databse Backup for Development
18
23
 
19
24
  1. Fork this project.
@@ -21,7 +26,7 @@ This backup utility is to make sure there is a recent backup of the database inc
21
26
  3. Code away!
22
27
 
23
28
  == Contributing to ey_db_export
24
-
29
+
25
30
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
26
31
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
27
32
  * Fork the project
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ Jeweler::Tasks.new do |gem|
20
20
  gem.homepage = "http://github.com/brettchalupa/ey_db_backup"
21
21
  gem.license = "MIT"
22
22
  gem.summary = %Q{Gem interacts with Amazon's S3 service to import the latest database backup.}
23
- gem.description = %Q{This gem interacts with Amazon's S3 service to give the user the ability to backup their database and store it elsewhere in case S3 experiences an outage. This gem should allow the user to easily automate the process of grabbing the most recent database from S3.}
23
+ gem.description = %Q{This gem interacts with Amazon's S3 service to give the user the ability to backup their Engine Yard databases and store them locally. This gem should allow the user to easily automate the process of grabbing the most recent database backup from S3. You can include as many databases in an environment as desired. To get started, check out the documentation.}
24
24
  gem.email = "brettchalupa@gmail.com"
25
25
  gem.authors = ["Brett Chalupa"]
26
26
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
data/ey_db_backup.gemspec CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ey_db_backup}
8
- s.version = "1.1.0"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brett Chalupa"]
12
12
  s.date = %q{2011-08-19}
13
13
  s.default_executable = %q{ey_db_backup}
14
- s.description = %q{This gem interacts with Amazon's S3 service to give the user the ability to backup their database and store it elsewhere in case S3 experiences an outage. This gem should allow the user to easily automate the process of grabbing the most recent database from S3.}
14
+ s.description = %q{This gem interacts with Amazon's S3 service to give the user the ability to backup their Engine Yard databases and store them locally. This gem should allow the user to easily automate the process of grabbing the most recent database backup from S3. You can include as many databases in an environment as desired. To get started, check out the documentation.}
15
15
  s.email = %q{brettchalupa@gmail.com}
16
16
  s.executables = ["ey_db_backup"]
17
17
  s.extra_rdoc_files = [
@@ -2,8 +2,7 @@ Feature: Exporting database from Engine Yard
2
2
  As a developer
3
3
  I want to export the latest database from Engine Yard
4
4
  So that I have a backup of the database hosted on another server that isn't Amazon's S3
5
-
6
- @wip
5
+
7
6
  Scenario: Successfully downloading the database
8
7
  Given I have Amazon S3 credentials located in a file
9
8
  And I have a database backup on Amazon S3
@@ -5,6 +5,8 @@ class AWSConfiguration
5
5
  attr_accessor :secret_access_key
6
6
  attr_accessor :bucket_name
7
7
  attr_accessor :export_path
8
+ attr_accessor :environment
9
+ attr_accessor :databases
8
10
 
9
11
  def read_from_yaml
10
12
  s3_credentials_yml = YAML.load_file("config/config.yml")
@@ -12,6 +14,8 @@ class AWSConfiguration
12
14
  @secret_access_key = s3_credentials_yml["secret_access_key"]
13
15
  @bucket_name = s3_credentials_yml["bucket_name"]
14
16
  @export_path = s3_credentials_yml["export_path"]
17
+ @environment = s3_credentials_yml["environment"]
18
+ @databases = s3_credentials_yml["databases"]
15
19
  end
16
20
 
17
21
  end
@@ -17,30 +17,68 @@ class DatabaseExport < Thor
17
17
 
18
18
  bucket_name = aws_config.bucket_name
19
19
  export_path = aws_config.export_path
20
+ environment = aws_config.environment
21
+ databases = aws_config.databases
20
22
 
21
- bucket_files = AWS::S3::Bucket.objects(bucket_name)
22
-
23
+ databases.each do |m|
23
24
 
24
- most_recent = bucket_files[0]
25
+ bucket_files = AWS::S3::Bucket.objects(bucket_name)
25
26
 
26
- bucket_files.each do |n|
27
- if n.about["last-modified"] > most_recent.about["last-modified"]
28
- most_recent = n
27
+ bucket_files.each do |x|
28
+ puts x.key
29
29
  end
30
- end
31
30
 
32
- chunk_total = 0
33
31
 
34
- puts "Backing up #{most_recent.key} to #{export_path}"
35
- puts "Current transfer status:"
32
+ bucket_files.keep_if {|v| v.key.include? m}
33
+
34
+ puts "-------"
36
35
 
37
- open("#{export_path}#{most_recent.key}", 'w') do |file|
38
- AWS::S3::S3Object.stream(most_recent.key, bucket_name) do |chunk|
39
- file.write chunk
40
- print "#{(((file.size.to_f)/(most_recent.about["content-length"].to_f))*100.0).truncate}% "
36
+ bucket_files.each do |x|
37
+ puts x.key
38
+ end
39
+
40
+ bucket_files.each do |k|
41
+ puts k.key
42
+ end
43
+
44
+ most_recent = bucket_files[0]
45
+
46
+ bucket_files.each do |n|
47
+ if n.about["last-modified"] > most_recent.about["last-modified"]
48
+ most_recent = n
41
49
  end
50
+ end
51
+
52
+ puts "Backing up #{most_recent.key} to #{export_path}#{most_recent.key}"
53
+ puts "Current transfer status:"
54
+
55
+ if !FileTest::directory?("#{export_path}#{environment}.#{m}")
56
+ Dir::mkdir("#{export_path}#{environment}.#{m}")
57
+ end
58
+
59
+ counter = 0
60
+
61
+ puts most_recent.about["content-length"]
62
+
63
+ open("#{export_path}#{most_recent.key}", 'w') do |file|
64
+ AWS::S3::S3Object.stream(most_recent.key, bucket_name) do |chunk|
65
+ file.write chunk
66
+ counter = counter + 1
67
+ if counter == ((((most_recent.about["content-length"].to_f/10.0)/1048576)*100).truncate).to_i or ((((file.size.to_f)/(most_recent.about["content-length"].to_f))*100.0).truncate == 100)
68
+ print "#{(((file.size.to_f)/(most_recent.about["content-length"].to_f))*100.0).truncate}% "
69
+ counter = 0
70
+ end
71
+
72
+ end
73
+ end
74
+
75
+ puts "\nBackup of #{most_recent.key} complete"
76
+
77
+ end
78
+
79
+ if databases.length > 1
80
+ puts "All backups complete"
42
81
  end
43
82
 
44
- puts "\nBackup complete"
45
83
  end
46
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ey_db_backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ default_executable: ey_db_backup
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
17
- requirement: &70264077838440 !ruby/object:Gem::Requirement
17
+ requirement: &70165758574820 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70264077838440
25
+ version_requirements: *70165758574820
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: aws-s3
28
- requirement: &70264077837900 !ruby/object:Gem::Requirement
28
+ requirement: &70165758574320 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70264077837900
36
+ version_requirements: *70165758574320
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &70264077837420 !ruby/object:Gem::Requirement
39
+ requirement: &70165758573840 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: 2.3.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70264077837420
47
+ version_requirements: *70165758573840
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: cucumber
50
- requirement: &70264077836860 !ruby/object:Gem::Requirement
50
+ requirement: &70165758573340 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70264077836860
58
+ version_requirements: *70165758573340
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: bundler
61
- requirement: &70264077836380 !ruby/object:Gem::Requirement
61
+ requirement: &70165758572820 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 1.0.0
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70264077836380
69
+ version_requirements: *70165758572820
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: jeweler
72
- requirement: &70264077835880 !ruby/object:Gem::Requirement
72
+ requirement: &70165758572340 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 1.6.4
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70264077835880
80
+ version_requirements: *70165758572340
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rcov
83
- requirement: &70264077835340 !ruby/object:Gem::Requirement
83
+ requirement: &70165758571840 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: '0'
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *70264077835340
91
+ version_requirements: *70165758571840
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: mock-aws-s3
94
- requirement: &70264077834820 !ruby/object:Gem::Requirement
94
+ requirement: &70165758571340 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ! '>='
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: '0'
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *70264077834820
102
+ version_requirements: *70165758571340
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: aws-s3
105
- requirement: &70264077834300 !ruby/object:Gem::Requirement
105
+ requirement: &70165758570840 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,11 +110,12 @@ dependencies:
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *70264077834300
113
+ version_requirements: *70165758570840
114
114
  description: This gem interacts with Amazon's S3 service to give the user the ability
115
- to backup their database and store it elsewhere in case S3 experiences an outage.
116
- This gem should allow the user to easily automate the process of grabbing the most
117
- recent database from S3.
115
+ to backup their Engine Yard databases and store them locally. This gem should allow
116
+ the user to easily automate the process of grabbing the most recent database backup
117
+ from S3. You can include as many databases in an environment as desired. To get
118
+ started, check out the documentation.
118
119
  email: brettchalupa@gmail.com
119
120
  executables:
120
121
  - ey_db_backup
@@ -171,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
172
  version: '0'
172
173
  segments:
173
174
  - 0
174
- hash: 3578843560886165085
175
+ hash: 2009758998784942013
175
176
  required_rubygems_version: !ruby/object:Gem::Requirement
176
177
  none: false
177
178
  requirements: