backup2s3 0.2.4 → 0.2.5
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/README +23 -32
- data/Rakefile +1 -1
- data/backup2s3.gemspec +8 -9
- data/generators/backup2s3/backup2s3_generator.rb +3 -7
- data/generators/backup2s3/templates/backup2s3.rake +1 -9
- data/generators/backup2s3/templates/backup2s3.yml +33 -3
- data/lib/adapters/s3_adapter.rb +1 -8
- data/lib/adapters/s3cmd_adapter.rb +1 -18
- data/lib/backup2s3.rb +2 -2
- data/lib/backup_management/backup_manager.rb +1 -1
- data/lib/system.rb +8 -0
- metadata +6 -8
data/README
CHANGED
@@ -1,52 +1,43 @@
|
|
1
|
-
SETUP
|
1
|
+
SETUP
|
2
2
|
|
3
|
-
|
4
|
-
|
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
|
-
|
16
|
+
USAGE (rake tasks)
|
17
|
+
|
21
18
|
|
22
|
-
|
19
|
+
Create -- Creates a backup and moves it to S3
|
20
|
+
-- comment - Add notes here to mark specific backups (optional)
|
23
21
|
|
24
|
-
|
25
|
-
|
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
|
-
|
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
|
-
|
38
|
-
|
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
|
-
|
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.
|
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.
|
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 = [
|
9
|
-
s.date = %q{2011-
|
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 = [
|
13
|
-
s.files = [
|
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 = [
|
16
|
-
s.require_paths = [
|
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.
|
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
|
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
|
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
|
-
#
|
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
|
data/lib/adapters/s3_adapter.rb
CHANGED
@@ -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..."
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
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-
|
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.
|
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.
|