backup2s3 0.3.2 → 0.4.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f58b0ef5185eff5b147692ad0768e379ce41df17
4
+ data.tar.gz: 48f6aad716910f40af96ec93c86298dfd3fd42bd
5
+ SHA512:
6
+ metadata.gz: a9c4bb2f23927e8f4212a294b32a436c385189b1fcb85afcfab4eeaa56ae0897acee52fe1588d34639972b209aaba065694937555001208c3472e95f3d2cd269
7
+ data.tar.gz: dc148b3ff747866c4da0882e40152478945a8dab0ca5dc71dd26dab9ae26a98315dfd412e36cf6c709b6431006ce6d302fd9976422f963e9c0b8c0e5909db2d6
@@ -3,20 +3,26 @@ require 'active_support'
3
3
  require 'tempfile'
4
4
  require 'yaml'
5
5
 
6
- require 'system.rb'
7
- require 'adapters/s3_adapter.rb'
8
- require 'adapters/s3cmd_adapter.rb'
9
- require 'backup_management/backup.rb'
10
- require 'backup_management/backup_manager.rb'
6
+ require 'system'
7
+ require 's3_adapters/aws_adapter'
8
+ require 's3_adapters/s3cmd_adapter'
9
+ require 'db_adapters/mysql_adapter'
10
+ require 'db_adapters/postgresql_adapter'
11
+ require 'backup_management/backup'
12
+ require 'backup_management/backup_manager'
11
13
 
12
14
  class Backup2s3
13
15
  include System
14
16
 
17
+ POSTGRESQL = 'postgresql'
18
+ MYSQL = 'mysql'
19
+
15
20
  def initialize
16
21
  STDOUT.sync = true #used so that print will not buffer output
17
22
  #ActiveResource::Base.logger = true
18
23
  load_configuration
19
- load_adapter
24
+ load_s3_adapter
25
+ load_db_adapter
20
26
  load_backup_manager
21
27
  @database_file = ""
22
28
  @application_file = ""
@@ -59,18 +65,18 @@ class Backup2s3
59
65
  if @conf[:backups][:backup_database]
60
66
  @database_file = System.clean("#{@time}-#{System.db_credentials['database']}-database") << ".sql"
61
67
  print "\nDumping database..."
62
- database_temp = System.db_dump
68
+ database_temp = @db_adapter.db_dump
63
69
  puts "\ndone\n- Database dump file size: " << database_temp.size.to_s << " B"; print "Backing up database dump file..."
64
- @adapter.store(@database_file, open(database_temp.path))
70
+ @s3_adapter.store(@database_file, open(database_temp.path))
65
71
  puts "done"
66
72
  end
67
-
73
+
68
74
  if @conf[:backups][:backup_application_folders].is_a?(Array)
69
75
  @application_file = System.clean("#{@time}-#{System.db_credentials['database']}-application") << ".tar.gz"
70
76
  print "\nZipping application folders..."
71
77
  application_temp = System.tarzip_folders(@conf[:backups][:backup_application_folders])
72
78
  puts "\ndone\n- Application tarball size: " << application_temp.size.to_s << " B"; print "Backing up application tarball..."
73
- @adapter.store(@application_file, open(application_temp.path))
79
+ @s3_adapter.store(@application_file, open(application_temp.path))
74
80
  puts "done"
75
81
  end
76
82
 
@@ -85,7 +91,7 @@ class Backup2s3
85
91
  end
86
92
 
87
93
  # Deletes the Backup, application backup files and database files associated
88
- # with the Backup identified by backup_id.
94
+ # with the Backup identified by backup_id.
89
95
  def delete_backup(backup_id)
90
96
  backup = @backup_manager.get_backup(backup_id)
91
97
  if backup.nil? then
@@ -93,10 +99,10 @@ class Backup2s3
93
99
  return
94
100
  end
95
101
  if !backup.application_file.empty?
96
- begin @adapter.delete(backup.application_file) rescue puts "Could not delete #{backup.application_file}!" end
102
+ begin @s3_adapter.delete(backup.application_file) rescue puts "Could not delete #{backup.application_file}!" end
97
103
  end
98
104
  if !backup.database_file.empty?
99
- begin @adapter.delete(backup.database_file) rescue puts "Could not delete #{backup.database_file}!" end
105
+ begin @s3_adapter.delete(backup.database_file) rescue puts "Could not delete #{backup.database_file}!" end
100
106
  end
101
107
  puts (@backup_manager.delete_backup(backup) ?
102
108
  "Backup with ID #{backup.time} was successfully deleted." :
@@ -110,7 +116,7 @@ class Backup2s3
110
116
  return
111
117
  end
112
118
  print "\nRetrieving application tarball..."
113
- application_file = @adapter.fetch(backup.application_file)
119
+ application_file = @s3_adapter.fetch(backup.application_file)
114
120
  puts "done"
115
121
 
116
122
  print "Restoring application from application tarball..."
@@ -118,11 +124,11 @@ class Backup2s3
118
124
  puts "done\n"
119
125
 
120
126
  print "\nRetrieving database dump_file..."
121
- dump_file = @adapter.fetch(backup.database_file)
127
+ dump_file = @s3_adapter.fetch(backup.database_file)
122
128
  puts "done";
123
129
 
124
- print "Restoring database from database dump file..."
125
- System.load_db_dump(dump_file)
130
+ puts "Restoring database from database dump file...\n"
131
+ @db_adapter.load_db_dump(dump_file)
126
132
  puts "done\n\n"
127
133
  end
128
134
 
@@ -132,20 +138,31 @@ class Backup2s3
132
138
  end
133
139
 
134
140
  # Creates instance of class used to interface with S3
135
- def load_adapter
141
+ def load_s3_adapter
136
142
  begin
137
143
  adapter = "#{@conf[:adapter][:type]}".constantize
138
144
  rescue
139
- adapter = S3Adapter
145
+ adapter = AwsAdapter
146
+ end
147
+ @s3_adapter = adapter.new(@conf[:adapter])
148
+ end
149
+
150
+ # Creates instance of class used to interface with the DB
151
+ def load_db_adapter
152
+ db_credentials = System.db_credentials
153
+ @db_adapter = nil
154
+ @db_adapter ||= PostgresqlAdapter.new(db_credentials) if db_credentials['adapter'].include?(POSTGRESQL)
155
+ @db_adapter ||= MysqlAdapter.new(db_credentials) if db_credentials['adapter'].include?(MYSQL)
156
+ if @db_adapter.nil?
157
+ raise "Backup2s3 only supports database backups for MySQL or PostgreSQL."
140
158
  end
141
- @adapter = adapter.new(@conf[:adapter])
142
159
  end
143
160
 
144
161
  def load_backup_manager
145
162
  BackupManager.new()
146
163
  Backup.new(nil, nil, nil)
147
164
  begin
148
- @backup_manager = YAML.load_file(@adapter.fetch(BackupManager.filename).path)
165
+ @backup_manager = YAML.load_file(@s3_adapter.fetch(BackupManager.filename).path)
149
166
  @backup_manager ||= YAML.load_file(BackupManager.local_filename)
150
167
  rescue
151
168
  @backup_manager ||= BackupManager.new
@@ -159,10 +176,10 @@ class Backup2s3
159
176
  puts "Unable to save local file: " << BackupManager.local_filename
160
177
  end
161
178
  begin
162
- @adapter.store(BackupManager.filename, open(BackupManager.local_filename))
179
+ @s3_adapter.store(BackupManager.filename, open(BackupManager.local_filename))
163
180
  rescue
164
181
  puts "Unable to save BackupManager to S3"
165
182
  end
166
- end
183
+ end
167
184
 
168
185
  end
@@ -5,7 +5,7 @@ require 'yaml'
5
5
  class Backup
6
6
 
7
7
  attr_accessor :time, :application_file, :database_file, :comment
8
-
8
+
9
9
  def initialize(time, application_file, database_file, comment = nil)
10
10
  self.time = time
11
11
  self.application_file = application_file
@@ -2,11 +2,11 @@ require 'yaml'
2
2
 
3
3
  class BackupManager
4
4
  include System
5
-
5
+
6
6
  attr_accessor :backup_list_filename, :backups
7
7
 
8
8
 
9
- def initialize
9
+ def initialize
10
10
  self.backups = Array.new
11
11
  end
12
12
 
@@ -61,10 +61,10 @@ class BackupManager
61
61
  count = count.next
62
62
  end
63
63
  puts "-----------------------\n\n"
64
- end
64
+ end
65
65
 
66
66
  def number_of_backups
67
67
  backups.size
68
68
  end
69
-
69
+
70
70
  end
@@ -0,0 +1,36 @@
1
+
2
+ class MysqlAdapter
3
+ include System
4
+
5
+ def initialize(db_credentials)
6
+ @db_credentials = db_credentials
7
+ end
8
+
9
+ # Creates and runs mysqldump and throws into .tar.gz file.
10
+ # Returns .tar.gz file
11
+ def db_dump
12
+ dump_file = Tempfile.new("dump")
13
+ cmd = "mysqldump --quick --single-transaction --create-options #{db_options}"
14
+ cmd += " > #{dump_file.path}"
15
+ System.run(cmd)
16
+ return dump_file
17
+ end
18
+
19
+ def load_db_dump(dump_file)
20
+ cmd = "mysql #{db_options}"
21
+ cmd += " < #{dump_file.path}"
22
+ System.run(cmd)
23
+ true
24
+ end
25
+
26
+ private
27
+
28
+ def db_options
29
+ cmd = ''
30
+ cmd += " -u #{@db_credentials['username']} " unless @db_credentials['username'].nil?
31
+ cmd += " -p'#{@db_credentials['password']}'" unless @db_credentials['password'].nil?
32
+ cmd += " -h '#{@db_credentials['host']}'" unless @db_credentials['host'].nil?
33
+ cmd += " #{@db_credentials['database']}"
34
+ end
35
+
36
+ end
@@ -0,0 +1,32 @@
1
+ class PostgresqlAdapter
2
+ include System
3
+
4
+ def initialize(db_credentials)
5
+ @db_credentials = db_credentials
6
+ end
7
+
8
+ # Creates and runs pg_dump and throws into .tar.gz file.
9
+ # Returns .tar.gz file
10
+ def db_dump
11
+ dump_file = Tempfile.new("dump")
12
+ password = @db_credentials['password']
13
+ database = @db_credentials['database']
14
+ cmd = "PGPASSWORD=\"#{password}\" pg_dump -Ft #{database} > #{dump_file.path}"
15
+ System.run(cmd)
16
+ dump_file
17
+ end
18
+
19
+ def load_db_dump(dump_file)
20
+ database = @db_credentials['database']
21
+ host = @db_credentials['host'] || 'localhost'
22
+ superuser = System.prompt "Postgres superuser: "
23
+ su_password = System.prompt "#{superuser} password: "
24
+ cmd = "PGPASSWORD=\"#{su_password}\" && PGUSER=\"#{superuser}\"; " +
25
+ "dropdb --host #{host} #{database}; " +
26
+ "createdb --host #{host} -T template0 #{database}; " +
27
+ "pg_restore --host #{host} -Ft --dbname=#{database} #{dump_file.path}"
28
+ System.run(cmd)
29
+ end
30
+
31
+ end
32
+
@@ -3,11 +3,11 @@ class Backup2s3Generator < Rails::Generators::Base
3
3
  def self.source_root
4
4
  @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
5
5
  end
6
-
7
- def generate
6
+
7
+ def generate
8
8
  copy_file("backup2s3.rake", "lib/tasks/backup2s3.rake")
9
9
  copy_file("backup2s3.yml", "config/backup2s3.yml")
10
- puts message
10
+ puts message
11
11
  end
12
12
 
13
13
  def message
@@ -49,7 +49,7 @@ class Backup2s3Generator < Rails::Generators::Base
49
49
  Restore -- Restores a backup specified by id parameter
50
50
  -- id - Backup to restore, backup ids will be found using List
51
51
 
52
- rake backup2s3:backup:restore id='20100913180541'
52
+ rake backup2s3:backup:restore id='20100913180541'
53
53
 
54
54
  -------------------------------------------------------------------
55
55
 
@@ -21,5 +21,5 @@ namespace :backup2s3 do
21
21
  task :restore do
22
22
  Backup2s3.new.restore
23
23
  end
24
- end
24
+ end
25
25
  end
@@ -2,36 +2,35 @@
2
2
  #
3
3
  # -backups section-
4
4
  #
5
- # :max_number_of_backups - Sets the number of backups to keep related to this
6
- # application on your S3 account. When the limit is
7
- # reached, the oldest backup will be deleted.
8
- # :backup_database - This is a boolean value. Backup2s3 will backup your
9
- # database if this is true and skip database backup if false.
5
+ # :max_number_of_backups ----- Sets the number of backups to keep related to this
6
+ # application on your S3 account. When the limit is
7
+ # reached, the oldest backup will be deleted.
8
+ #
9
+ # :backup_database ----------- This is a boolean value. Backup2s3 will backup your
10
+ # database if this is true and skip database backup if false.
11
+ #
10
12
  # :backup_application_folder - An array of the top level application folders
11
13
  # that Backup2s3 should tar, zip and backup to S3.
12
14
  #
13
15
  #
14
16
  # -adapter section-
15
17
  #
16
- # :type - The adapter type you would like to use.
18
+ # :type ---------------------- The adapter type you would like to use.
17
19
  #
18
20
  # Currently available adapter types:
19
- # S3Adapter - Uses aws-s3 gem and does not provide a status/percentage
20
- # report, failsafe or throttling.
21
- # S3cmdAdapter - Uses s3cmd 0.9.9.91 Python library found here:
22
- # http://s3tools.org/s3cmd
23
- # This adapter displays upload progress and also has
24
- # failsafes and throttling incase an upload fails.
25
- # The failsafe will slow the upload speed and retry
26
- # the upload incase of failure.
27
21
  #
28
- # :access_key_id - Your Amazon S3 access key id
22
+ # AwsAdapter ----- Uses aws-sdk gem V1.
29
23
  #
30
- # :secret_access_key - Your Amazon S3 secret access key
24
+ # S3cmdAdapter --- Uses s3cmd 0.9.9.91 Python library found here: http://s3tools.org/s3cmd
25
+ # This adapter displays upload progress and also has
26
+ # failsafes and throttling incase an upload fails.
27
+ # The failsafe will slow the upload speed and retry
28
+ # the upload incase of failure.
31
29
  #
32
- # :use_ssl - Uses an ssl connection for backups if set to true.
30
+ # :access_key_id ------------- Your Amazon S3 access key id
31
+ #
32
+ # :secret_access_key --------- Your Amazon S3 secret access key
33
33
  #
34
-
35
34
 
36
35
 
37
36
 
@@ -39,14 +38,14 @@
39
38
  :max_number_of_backups: 5
40
39
  :backup_database: true
41
40
  :backup_application_folders:
42
- - public
41
+ - public
43
42
  - lib
44
43
 
45
44
  :adapter:
46
- :type: S3Adapter
45
+ :type: AwsAdapter
47
46
  :access_key_id: XXXXXXXXXXXXXXXXXXXX
48
47
  :secret_access_key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
49
- :use_ssl: true
48
+ :region: ~
50
49
 
51
50
 
52
51
 
@@ -0,0 +1,66 @@
1
+ require 'aws-sdk'
2
+
3
+ class AwsAdapter
4
+ include System
5
+
6
+ DEFAULT_REGION = 'us-east-1'
7
+
8
+ def initialize(config)
9
+ @config = config
10
+ @connected = false
11
+ @bucket = nil
12
+ end
13
+
14
+ def ensure_connected
15
+ return if @connected
16
+ client = AWS::S3.new(:access_key_id => @config[:access_key_id],
17
+ :secret_access_key => @config[:secret_access_key])
18
+
19
+ begin
20
+ create_bucket(client)
21
+ @connected = true
22
+ rescue Exception => e
23
+ puts "Unable to create bucket -- #{e}"
24
+ @connected = false
25
+ end
26
+ end
27
+
28
+ def store(file_name, file)
29
+ ensure_connected
30
+ bucket_object = @bucket.objects[file_name]
31
+ bucket_object.write(Pathname.new(file.path))
32
+ end
33
+
34
+ def fetch(file_name)
35
+ ensure_connected
36
+ file = Tempfile.new("temp")
37
+ bucket_object = @bucket.objects[file_name]
38
+
39
+ File.open(file.path, 'wb') do |f|
40
+ bucket_object.read do |chunk|
41
+ f.write chunk
42
+ end
43
+ end
44
+ return file
45
+ end
46
+
47
+ def delete(file_name)
48
+ ensure_connected
49
+ @bucket.objects[file_name].delete
50
+ end
51
+
52
+ private
53
+
54
+ # TODO move to abstract class
55
+ def create_bucket(client)
56
+ if @bucket.nil?
57
+ bucket_name = System.clean("#{System.db_credentials['database'].downcase}-ON-#{System.hostname.downcase}")
58
+ @bucket = client.buckets[bucket_name]
59
+ @bucket = client.buckets.create(bucket_name) if !@bucket.exists?
60
+ end
61
+ @bucket
62
+ end
63
+
64
+ end
65
+
66
+
@@ -26,7 +26,7 @@ class S3cmdAdapter
26
26
  end
27
27
 
28
28
  def delete(file_name)
29
- #TODO use s3cmd ls here to create 'find' like functionality similar to s3_adapter
29
+ #TODO use s3cmd ls here to create 'find' like functionality similar to aws_adapter
30
30
  begin
31
31
  System.run("s3cmd del s3://#{bucket}/#{file_name}")
32
32
  rescue
@@ -36,6 +36,7 @@ class S3cmdAdapter
36
36
 
37
37
  private
38
38
 
39
+ # TODO move to abstract class
39
40
  def bucket
40
41
  @bucket ||= System.clean("#{System.db_credentials['database'].downcase}-ON-#{System.hostname.downcase}")
41
42
  end
@@ -20,19 +20,19 @@ module System
20
20
 
21
21
  # Creates app tar file
22
22
  def self.tarzip_folders(folders)
23
- application_tar = Tempfile.new("app")
23
+ application_tar = Tempfile.new("app")
24
24
  ex_folders = ''
25
- folders.each { |folder|
26
- unless File.exist?(folder)
25
+ folders.each { |folder|
26
+ unless File.exist?(folder)
27
27
  print "\nWARNING: Folder \'" + folder + "\' does not exist! Excluding from backup."
28
28
  else
29
29
  ex_folders << folder << ' '
30
- end
31
- }
30
+ end
31
+ }
32
32
  if ex_folders.length > 0
33
33
  cmd = "tar --dereference -czpf #{application_tar.path} #{ex_folders}"
34
34
  run(cmd)
35
- end
35
+ end
36
36
  return application_tar
37
37
  end
38
38
 
@@ -41,31 +41,6 @@ module System
41
41
  run(cmd)
42
42
  end
43
43
 
44
- # Creates and runs mysqldump and throws into .tar.gz file.
45
- # Returns .tar.gz file
46
- def self.db_dump
47
- dump_file = Tempfile.new("dump")
48
- cmd = "mysqldump --quick --single-transaction --create-options #{mysql_options}"
49
- cmd += " > #{dump_file.path}"
50
- run(cmd)
51
- return dump_file
52
- end
53
-
54
- def self.load_db_dump(dump_file)
55
- cmd = "mysql #{mysql_options}"
56
- cmd += " < #{dump_file.path}"
57
- run(cmd)
58
- true
59
- end
60
-
61
- def self.mysql_options
62
- cmd = ''
63
- cmd += " -u #{db_credentials['username']} " unless db_credentials['username'].nil?
64
- cmd += " -p'#{db_credentials['password']}'" unless db_credentials['password'].nil?
65
- cmd += " -h '#{db_credentials['host']}'" unless db_credentials['host'].nil?
66
- cmd += " #{db_credentials['database']}"
67
- end
68
-
69
44
  def self.clean(str)
70
45
  str.gsub!(".", "-dot-")
71
46
  str.gsub!("_", "-")
@@ -73,6 +48,16 @@ module System
73
48
  str.gsub!(/[^0-9a-z\-_]/i, '')
74
49
  return str
75
50
  end
76
-
51
+
52
+ def self.prompt(prompt, noecho = false)
53
+ STDOUT.print prompt
54
+ STDOUT.flush
55
+ if noecho
56
+ return STDIN.noecho(&:gets).chomp
57
+ else
58
+ return STDIN.gets.chomp
59
+ end
60
+ end
61
+
77
62
  end
78
63
 
metadata CHANGED
@@ -1,112 +1,76 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: backup2s3
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease:
6
- segments:
7
- - 0
8
- - 3
9
- - 2
10
- version: 0.3.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.0.pre
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Aric Walker
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-08-16 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: aws-s3
11
+ date: 2014-12-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.59'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.59.0
23
+ type: :runtime
22
24
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.59'
26
30
  - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- - 6
32
- - 2
33
- version: 0.6.2
34
- type: :development
35
- version_requirements: *id001
36
- description: Backup2s3 is a gem that performs database and application backups and stores this data on Amazon S3.
37
- email: aric@truespire.com
31
+ - !ruby/object:Gem::Version
32
+ version: 1.59.0
33
+ description: Backup2s3 is a gem that performs database and application backups and
34
+ stores the data on Amazon S3.
35
+ email:
36
+ - aric.walker@gmail.com
38
37
  executables: []
39
-
40
38
  extensions: []
41
-
42
- extra_rdoc_files:
43
- - CHANGELOG
44
- - README
45
- - lib/adapters/s3_adapter.rb
46
- - lib/adapters/s3cmd_adapter.rb
39
+ extra_rdoc_files: []
40
+ files:
47
41
  - lib/backup2s3.rb
48
42
  - lib/backup_management/backup.rb
49
43
  - lib/backup_management/backup_manager.rb
50
- - lib/generators/backup2s3/USAGE
44
+ - lib/db_adapters/mysql_adapter.rb
45
+ - lib/db_adapters/postgresql_adapter.rb
51
46
  - lib/generators/backup2s3/backup2s3_generator.rb
52
47
  - lib/generators/backup2s3/templates/backup2s3.rake
53
48
  - lib/generators/backup2s3/templates/backup2s3.yml
49
+ - lib/s3_adapters/aws_adapter.rb
50
+ - lib/s3_adapters/s3cmd_adapter.rb
54
51
  - lib/system.rb
55
- files:
56
- - CHANGELOG
57
- - Manifest
58
- - README
59
- - Rakefile
60
- - init.rb
61
- - lib/adapters/s3_adapter.rb
62
- - lib/adapters/s3cmd_adapter.rb
63
- - lib/backup2s3.rb
64
- - lib/backup_management/backup.rb
65
- - lib/backup_management/backup_manager.rb
66
- - lib/generators/backup2s3/USAGE
67
- - lib/generators/backup2s3/backup2s3_generator.rb
68
- - lib/generators/backup2s3/templates/backup2s3.rake
69
- - lib/generators/backup2s3/templates/backup2s3.yml
70
- - lib/system.rb
71
- - backup2s3.gemspec
72
- homepage: http://github.com/aricwalker/backup2s3
73
- licenses: []
74
-
52
+ homepage: http://rubygems.org/gems/backup2s3
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
75
56
  post_install_message:
76
- rdoc_options:
77
- - --line-numbers
78
- - --inline-source
79
- - --title
80
- - Backup2s3
81
- - --main
82
- - README
83
- require_paths:
57
+ rdoc_options: []
58
+ require_paths:
84
59
  - lib
85
- required_ruby_version: !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 0
93
- version: "0"
94
- required_rubygems_version: !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
97
62
  - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 11
100
- segments:
101
- - 1
102
- - 2
103
- version: "1.2"
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">"
68
+ - !ruby/object:Gem::Version
69
+ version: 1.3.1
104
70
  requirements: []
105
-
106
- rubyforge_project: backup2s3
107
- rubygems_version: 1.8.5
71
+ rubyforge_project:
72
+ rubygems_version: 2.4.4
108
73
  signing_key:
109
- specification_version: 3
110
- summary: Backup2s3 is a gem that creates, deletes and restores db and application backups.
74
+ specification_version: 4
75
+ summary: Backup2s3
111
76
  test_files: []
112
-
data/CHANGELOG DELETED
File without changes
data/Manifest DELETED
@@ -1,15 +0,0 @@
1
- CHANGELOG
2
- Manifest
3
- README
4
- Rakefile
5
- init.rb
6
- lib/adapters/s3_adapter.rb
7
- lib/adapters/s3cmd_adapter.rb
8
- lib/backup2s3.rb
9
- lib/backup_management/backup.rb
10
- lib/backup_management/backup_manager.rb
11
- lib/generators/backup2s3/USAGE
12
- lib/generators/backup2s3/backup2s3_generator.rb
13
- lib/generators/backup2s3/templates/backup2s3.rake
14
- lib/generators/backup2s3/templates/backup2s3.yml
15
- lib/system.rb
data/README DELETED
@@ -1,45 +0,0 @@
1
- SETUP
2
-
3
- 1. Install the gem
4
- gem install backup2s3
5
-
6
- 2. Add these dependencies to your application Gemfile
7
- gem 'backup2s3'
8
- gem 'aws-s3'
9
-
10
- 3. Run the generator in your application root directory
11
- rails g backup2s3
12
-
13
-
14
- 4. Change your settings in config/backup2s3.yml
15
-
16
-
17
-
18
- USAGE (rake tasks)
19
-
20
-
21
- Create -- Creates a backup and moves it to S3
22
- -- comment - Add notes here to mark specific backups (optional)
23
-
24
- rake backup2s3:backup:create
25
- rake backup2s3:backup:create comment='put notes about backup here if needed'
26
-
27
-
28
- Delete -- Deletes the specified backup
29
- -- id - Backup to delete, backup ids will be found using List
30
-
31
- rake backup2s3:backup:delete id='20100913180541'
32
-
33
-
34
- List -- Lists all backups that are currently on S3
35
- -- details - Setting details to true will display backup file names
36
- and backup comments (optional)
37
-
38
- rake backup2s3:backup:list
39
- rake backup2s3:backup:list details=true
40
-
41
-
42
- Restore -- Restores a specific backup
43
- -- id - Backup to restore, backup ids will be found using List task
44
-
45
- rake backup2s3:backup:restore id='20100913180541'
data/Rakefile DELETED
@@ -1,13 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'echoe'
4
-
5
- Echoe.new('backup2s3', '0.3.2') do |p|
6
- p.description = "Backup2s3 is a gem that performs database and application backups and stores this data on Amazon S3."
7
- p.summary = "Backup2s3 is a gem that creates, deletes and restores db and application backups."
8
- p.url = "http://github.com/aricwalker/backup2s3"
9
- p.author = "Aric Walker"
10
- p.email = "aric@truespire.com"
11
- p.ignore_pattern = ["nbproject/*/*", "nbproject/*"]
12
- p.development_dependencies = ["aws-s3 >=0.6.2"]
13
- end
@@ -1,32 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- Gem::Specification.new do |s|
4
- s.name = %q{backup2s3}
5
- s.version = "0.3.2"
6
-
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = [%q{Aric Walker}]
9
- s.date = %q{2011-08-16}
10
- s.description = %q{Backup2s3 is a gem that performs database and application backups and stores this data on Amazon S3.}
11
- s.email = %q{aric@truespire.com}
12
- s.extra_rdoc_files = [%q{CHANGELOG}, %q{README}, %q{lib/adapters/s3_adapter.rb}, %q{lib/adapters/s3cmd_adapter.rb}, %q{lib/backup2s3.rb}, %q{lib/backup_management/backup.rb}, %q{lib/backup_management/backup_manager.rb}, %q{lib/generators/backup2s3/USAGE}, %q{lib/generators/backup2s3/backup2s3_generator.rb}, %q{lib/generators/backup2s3/templates/backup2s3.rake}, %q{lib/generators/backup2s3/templates/backup2s3.yml}, %q{lib/system.rb}]
13
- s.files = [%q{CHANGELOG}, %q{Manifest}, %q{README}, %q{Rakefile}, %q{init.rb}, %q{lib/adapters/s3_adapter.rb}, %q{lib/adapters/s3cmd_adapter.rb}, %q{lib/backup2s3.rb}, %q{lib/backup_management/backup.rb}, %q{lib/backup_management/backup_manager.rb}, %q{lib/generators/backup2s3/USAGE}, %q{lib/generators/backup2s3/backup2s3_generator.rb}, %q{lib/generators/backup2s3/templates/backup2s3.rake}, %q{lib/generators/backup2s3/templates/backup2s3.yml}, %q{lib/system.rb}, %q{backup2s3.gemspec}]
14
- s.homepage = %q{http://github.com/aricwalker/backup2s3}
15
- s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Backup2s3}, %q{--main}, %q{README}]
16
- s.require_paths = [%q{lib}]
17
- s.rubyforge_project = %q{backup2s3}
18
- s.rubygems_version = %q{1.8.5}
19
- s.summary = %q{Backup2s3 is a gem that creates, deletes and restores db and application backups.}
20
-
21
- if s.respond_to? :specification_version then
22
- s.specification_version = 3
23
-
24
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
25
- s.add_development_dependency(%q<aws-s3>, [">= 0.6.2"])
26
- else
27
- s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
28
- end
29
- else
30
- s.add_dependency(%q<aws-s3>, [">= 0.6.2"])
31
- end
32
- end
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'backup2s3'
@@ -1,65 +0,0 @@
1
- require 'aws/s3'
2
-
3
-
4
- class S3Adapter
5
- include System
6
-
7
- def initialize(config)
8
- @config = config
9
- @connected = false
10
- end
11
-
12
- def ensure_connected
13
- return if @connected
14
- AWS::S3::Base.establish_connection!(
15
- :access_key_id => @config[:access_key_id],
16
- :secret_access_key => @config[:secret_access_key],
17
- :use_ssl => @config[:use_ssl]
18
- )
19
- AWS::S3::Bucket.create(bucket)
20
- @connected = true
21
- end
22
-
23
- def store(file_name, file)
24
- ensure_connected
25
- AWS::S3::S3Object.store(file_name, file, bucket)
26
- end
27
-
28
- def fetch(file_name)
29
- ensure_connected
30
- AWS::S3::S3Object.find(file_name, bucket)
31
-
32
- file = Tempfile.new("temp")
33
- open(file.path, 'w') do |f|
34
- AWS::S3::S3Object.stream(file_name, bucket) do |chunk|
35
- f.write chunk
36
- end
37
- end
38
- file
39
- end
40
-
41
- def read(file_name)
42
- ensure_connected
43
- return AWS::S3::S3Object.find(file_name, bucket)
44
- end
45
-
46
- def list
47
- ensure_connected
48
- AWS::S3::Bucket.find(bucket).objects.collect {|x| x.path }
49
- end
50
-
51
- def delete(file_name)
52
- if object = AWS::S3::S3Object.find(file_name, bucket)
53
- object.delete
54
- end
55
- end
56
-
57
- private
58
-
59
- def bucket
60
- @bucket ||= System.clean("#{System.db_credentials['database'].downcase}-ON-#{System.hostname.downcase}")
61
- end
62
-
63
- end
64
-
65
-
@@ -1 +0,0 @@
1
- backup2s3 generator