backup2s3 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,52 +1,43 @@
1
- SETUP:
1
+ SETUP
2
2
 
3
- 1. Install the gem
4
- gem install backup2s3
3
+ 1. Install the gem
4
+ gem install backup2s3
5
5
 
6
-
7
- 2. Add the below code to config/environment.rb
8
- config.gem "backup2s3", :version => ">= 0.2.3"
9
6
 
7
+ 2. Run the generator in your application root directory
8
+ script/generate backup2s3
10
9
 
11
- 3. Run the generator in your application root directory
12
- script/generate backup2s3
13
10
 
11
+ 3. Change your settings in config/backup2s3.yml
14
12
 
15
- 4. Change your settings in config/backup2s3.yml
16
13
 
17
14
 
18
- USAGE:
19
15
 
20
- 2. Get started.
16
+ USAGE (rake tasks)
17
+
21
18
 
22
- Backup tasks
19
+ Create -- Creates a backup and moves it to S3
20
+ -- comment - Add notes here to mark specific backups (optional)
23
21
 
24
- Create -- Creates a backup and moves it to S3
25
- -- comment - Add notes here to mark specific backups (optional)
22
+ rake backup2s3:backup:create
23
+ rake backup2s3:backup:create comment='put notes about backup here if needed'
26
24
 
27
- rake backup2s3:backup:create
28
- rake backup2s3:backup:create comment='put notes about backup here if needed'
29
25
 
26
+ Delete -- Deletes the specified backup
27
+ -- id - Backup to delete, backup ids will be found using List
30
28
 
31
- Delete -- Deletes the specific backup
32
- -- id - Backup to delete, backup ids will be found using List
29
+ rake backup2s3:backup:delete id='20100913180541'
33
30
 
34
- rake backup2s3:backup:delete id='20100913180541'
35
31
 
32
+ List -- Lists all backups that are currently on S3
33
+ -- details - Setting details to true will display backup file names
34
+ and backup comments (optional)
36
35
 
37
- List -- Lists all backups that are currently on S3
38
- -- details - Setting details to true will display backup file names
39
- and backup comments (optional)
36
+ rake backup2s3:backup:list
37
+ rake backup2s3:backup:list details=true
40
38
 
41
- rake backup2s3:backup:list
42
- rake backup2s3:backup:list details=true
43
39
 
40
+ Restore -- Restores a specific backup
41
+ -- id - Backup to restore, backup ids will be found using List task
44
42
 
45
- Restore -- Restores a specific backup
46
- -- id - Backup to restore, backup ids will be found using List
47
-
48
- rake backup2s3:backup:restore id='20100913180541'
49
-
50
- Some handy tasks
51
-
52
- rake backup2s3:statistics - Shows you the size of your DB
43
+ rake backup2s3:backup:restore id='20100913180541'
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('backup2s3', '0.2.4') do |p|
5
+ Echoe.new('backup2s3', '0.2.5') do |p|
6
6
  p.description = "Backup2s3 is a gem that performs database and application backups and stores this data on Amazon S3."
7
7
  p.summary = "Backup2s3 is a gem that creates, deletes and restores db and application backups."
8
8
  p.url = "http://github.com/aricwalker/backup2s3"
data/backup2s3.gemspec CHANGED
@@ -2,24 +2,23 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{backup2s3}
5
- s.version = "0.2.4"
5
+ s.version = "0.2.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Aric Walker"]
9
- s.date = %q{2011-03-18}
8
+ s.authors = [%q{Aric Walker}]
9
+ s.date = %q{2011-08-15}
10
10
  s.description = %q{Backup2s3 is a gem that performs database and application backups and stores this data on Amazon S3.}
11
11
  s.email = %q{aric@truespire.com}
12
- s.extra_rdoc_files = ["CHANGELOG", "README", "lib/adapters/s3_adapter.rb", "lib/adapters/s3cmd_adapter.rb", "lib/backup2s3.rb", "lib/backup_management/backup.rb", "lib/backup_management/backup_manager.rb", "lib/system.rb"]
13
- s.files = ["CHANGELOG", "Manifest", "README", "Rakefile", "generators/backup2s3/USAGE", "generators/backup2s3/backup2s3_generator.rb", "generators/backup2s3/templates/backup2s3.rake", "generators/backup2s3/templates/backup2s3.yml", "init.rb", "lib/adapters/s3_adapter.rb", "lib/adapters/s3cmd_adapter.rb", "lib/backup2s3.rb", "lib/backup_management/backup.rb", "lib/backup_management/backup_manager.rb", "lib/system.rb", "backup2s3.gemspec"]
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/system.rb}]
13
+ s.files = [%q{CHANGELOG}, %q{Manifest}, %q{README}, %q{Rakefile}, %q{generators/backup2s3/USAGE}, %q{generators/backup2s3/backup2s3_generator.rb}, %q{generators/backup2s3/templates/backup2s3.rake}, %q{generators/backup2s3/templates/backup2s3.yml}, %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/system.rb}, %q{backup2s3.gemspec}]
14
14
  s.homepage = %q{http://github.com/aricwalker/backup2s3}
15
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Backup2s3", "--main", "README"]
16
- s.require_paths = ["lib"]
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
17
  s.rubyforge_project = %q{backup2s3}
18
- s.rubygems_version = %q{1.3.7}
18
+ s.rubygems_version = %q{1.8.5}
19
19
  s.summary = %q{Backup2s3 is a gem that creates, deletes and restores db and application backups.}
20
20
 
21
21
  if s.respond_to? :specification_version then
22
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
22
  s.specification_version = 3
24
23
 
25
24
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -35,7 +35,7 @@ class Backup2s3Generator < Rails::Generator::Base
35
35
  rake backup2s3:backup:create comment='put notes about backup here if needed'
36
36
 
37
37
 
38
- Delete -- Deletes the specific backup
38
+ Delete -- Deletes a backup specified by id parameter
39
39
  -- id - Backup to delete, backup ids will be found using List
40
40
 
41
41
  rake backup2s3:backup:delete id='20100913180541'
@@ -49,14 +49,10 @@ class Backup2s3Generator < Rails::Generator::Base
49
49
  rake backup2s3:backup:list details=true
50
50
 
51
51
 
52
- Restore -- Restores a specific backup
52
+ Restore -- Restores a backup specified by id parameter
53
53
  -- id - Backup to restore, backup ids will be found using List
54
54
 
55
- rake backup2s3:backup:restore id='20100913180541'
56
-
57
- Some handy tasks
58
-
59
- rake backup2s3:statistics - Shows you the size of your DB
55
+ rake backup2s3:backup:restore id='20100913180541'
60
56
 
61
57
  -------------------------------------------------------------------
62
58
 
@@ -21,13 +21,5 @@ namespace :backup2s3 do
21
21
  task :restore do
22
22
  Backup2s3.new.restore
23
23
  end
24
- end
25
-
26
- desc "Show table sizes for your database"
27
- task :statistics => :environment do
28
- rows = Backup2s3.new.statistics
29
- rows.sort_by {|x| -x[3].to_i }
30
- header = [["Type", "Data MB", "Index", "Rows", "Name"], []]
31
- puts (header + rows).collect {|x| x.join("\t") }
32
- end
24
+ end
33
25
  end
@@ -1,10 +1,40 @@
1
1
  #Sample backup2s3 configuration file
2
2
  #
3
- # Available adapter types:
4
- # S3Adapter - Uses aws-s3 gem.
5
- # S3cmdAdapter - Uses s3cmd 0.9.9.91 Python library found here: http://s3tools.org/s3cmd
3
+ # -backups section-
6
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.
10
+ # :backup_application_folder - An array of the top level application folders
11
+ # that Backup2s3 should tar, zip and backup to S3.
7
12
  #
13
+ #
14
+ # -adapter section-
15
+ #
16
+ # :type - The adapter type you would like to use.
17
+ #
18
+ # 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
+ #
28
+ # :access_key_id - Your Amazon S3 access key id
29
+ #
30
+ # :secret_access_key - Your Amazon S3 secret access key
31
+ #
32
+ # :use_ssl - Uses an ssl connection for backups if set to true.
33
+ #
34
+
35
+
36
+
37
+
8
38
  :backups:
9
39
  :max_number_of_backups: 5
10
40
  :backup_database: true
@@ -57,14 +57,7 @@ class S3Adapter
57
57
  private
58
58
 
59
59
  def bucket
60
- @bucket ||= clean("#{System.db_credentials['database'].downcase}-ON-#{System.hostname.downcase}")
61
- end
62
-
63
- def clean(str)
64
- str.gsub!(".", "-dot-")
65
- str.gsub!("_", "-")
66
- str.gsub!("\n", "")
67
- return str
60
+ @bucket ||= System.clean("#{System.db_credentials['database'].downcase}-ON-#{System.hostname.downcase}")
68
61
  end
69
62
 
70
63
  end
@@ -25,16 +25,6 @@ class S3cmdAdapter
25
25
  file
26
26
  end
27
27
 
28
- # def read(file_name)
29
- # ensure_connected
30
- # return AWS::S3::S3Object.find(file_name, bucket)
31
- # end
32
-
33
- # def list
34
- # ensure_connected
35
- # AWS::S3::Bucket.find(bucket).objects.collect {|x| x.path }
36
- # end
37
-
38
28
  def delete(file_name)
39
29
  #TODO use s3cmd ls here to create 'find' like functionality similar to s3_adapter
40
30
  begin
@@ -47,14 +37,7 @@ class S3cmdAdapter
47
37
  private
48
38
 
49
39
  def bucket
50
- @bucket ||= clean("#{System.db_credentials['database'].downcase}-ON-#{System.hostname.downcase}")
51
- end
52
-
53
- def clean(str)
54
- str.gsub!(".", "-dot-")
55
- str.gsub!("_", "-")
56
- str.gsub!("\n", "")
57
- return str
40
+ @bucket ||= System.clean("#{System.db_credentials['database'].downcase}-ON-#{System.hostname.downcase}")
58
41
  end
59
42
 
60
43
  end
data/lib/backup2s3.rb CHANGED
@@ -57,7 +57,7 @@ class Backup2s3
57
57
  # information.
58
58
  def create_backup(comment)
59
59
  if @conf[:backups][:backup_database]
60
- @database_file = "#{@time}-#{System.db_credentials['database']}-database.sql"
60
+ @database_file = System.clean("#{@time}-#{System.db_credentials['database']}-database.sql")
61
61
  print "\nDumping database..."
62
62
  database_temp = System.db_dump
63
63
  puts "done\n- Database dump file size: " << database_temp.size.to_s << " B"; print "Backing up database dump file..."
@@ -66,7 +66,7 @@ class Backup2s3
66
66
  end
67
67
 
68
68
  if @conf[:backups][:backup_application_folders].is_a?(Array)
69
- @application_file = "#{@time}-#{System.db_credentials['database']}-application.tar.gz"
69
+ @application_file = System.clean("#{@time}-#{System.db_credentials['database']}-application.tar.gz")
70
70
  print "\nZipping application folders..."
71
71
  application_temp = System.tarzip_folders(@conf[:backups][:backup_application_folders])
72
72
  puts "done\n- Application tarball size: " << application_temp.size.to_s << " B"; print "Backing up application tarball..."
@@ -11,7 +11,7 @@ class BackupManager
11
11
  end
12
12
 
13
13
  def self.filename
14
- "#{System.db_credentials['database']}_ON_#{System.hostname}_backups.yaml"
14
+ System.clean("#{System.db_credentials['database']}_ON_#{System.hostname}_backups.yaml")
15
15
  end
16
16
 
17
17
  def self.local_filename
data/lib/system.rb CHANGED
@@ -59,6 +59,14 @@ module System
59
59
  cmd += " -h '#{db_credentials['host']}'" unless db_credentials['host'].nil?
60
60
  cmd += " #{db_credentials['database']}"
61
61
  end
62
+
63
+ def self.clean(str)
64
+ str.gsub!(".", "-dot-")
65
+ str.gsub!("_", "-")
66
+ str.gsub!("\n", "")
67
+ str.gsub!(/[^0-9a-z-_]/i, '')
68
+ return str
69
+ end
62
70
 
63
71
  end
64
72
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup2s3
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
5
- prerelease: false
4
+ hash: 29
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 4
10
- version: 0.2.4
9
+ - 5
10
+ version: 0.2.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aric Walker
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-18 00:00:00 -06:00
19
- default_executable:
18
+ date: 2011-08-15 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: aws-s3
@@ -66,7 +65,6 @@ files:
66
65
  - lib/backup_management/backup_manager.rb
67
66
  - lib/system.rb
68
67
  - backup2s3.gemspec
69
- has_rdoc: true
70
68
  homepage: http://github.com/aricwalker/backup2s3
71
69
  licenses: []
72
70
 
@@ -102,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
100
  requirements: []
103
101
 
104
102
  rubyforge_project: backup2s3
105
- rubygems_version: 1.3.7
103
+ rubygems_version: 1.8.5
106
104
  signing_key:
107
105
  specification_version: 3
108
106
  summary: Backup2s3 is a gem that creates, deletes and restores db and application backups.