backup-wakiki 2.4.1

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.
Files changed (54) hide show
  1. data/.document +5 -0
  2. data/.gitignore +5 -0
  3. data/CHANGELOG +77 -0
  4. data/LICENSE +9 -0
  5. data/README.textile +175 -0
  6. data/Rakefile +65 -0
  7. data/VERSION +1 -0
  8. data/backup-2.3.1.gem +0 -0
  9. data/backup-wakiki.gemspec +113 -0
  10. data/backup.gemspec +111 -0
  11. data/bin/backup +124 -0
  12. data/generators/backup/backup_generator.rb +72 -0
  13. data/generators/backup/templates/config/backup.rb +202 -0
  14. data/generators/backup/templates/migrations/create_backup_tables.rb +18 -0
  15. data/generators/backup/templates/tasks/backup.rake +71 -0
  16. data/generators/backup_update/backup_update_generator.rb +50 -0
  17. data/generators/backup_update/templates/migrations/update_backup_tables.rb +27 -0
  18. data/lib/backup.rb +112 -0
  19. data/lib/backup/adapters/archive.rb +34 -0
  20. data/lib/backup/adapters/base.rb +113 -0
  21. data/lib/backup/adapters/custom.rb +41 -0
  22. data/lib/backup/adapters/mysql.rb +60 -0
  23. data/lib/backup/adapters/postgresql.rb +56 -0
  24. data/lib/backup/adapters/sqlite.rb +25 -0
  25. data/lib/backup/command_helper.rb +11 -0
  26. data/lib/backup/configuration/adapter.rb +21 -0
  27. data/lib/backup/configuration/adapter_options.rb +8 -0
  28. data/lib/backup/configuration/attributes.rb +19 -0
  29. data/lib/backup/configuration/base.rb +55 -0
  30. data/lib/backup/configuration/helpers.rb +24 -0
  31. data/lib/backup/configuration/mail.rb +20 -0
  32. data/lib/backup/configuration/smtp.rb +8 -0
  33. data/lib/backup/configuration/storage.rb +8 -0
  34. data/lib/backup/connection/s3.rb +87 -0
  35. data/lib/backup/environment/base.rb +12 -0
  36. data/lib/backup/environment/rails.rb +17 -0
  37. data/lib/backup/environment/unix.rb +94 -0
  38. data/lib/backup/mail/base.rb +96 -0
  39. data/lib/backup/mail/mail.txt +7 -0
  40. data/lib/backup/record/base.rb +65 -0
  41. data/lib/backup/record/ftp.rb +39 -0
  42. data/lib/backup/record/local.rb +26 -0
  43. data/lib/backup/record/s3.rb +26 -0
  44. data/lib/backup/record/scp.rb +33 -0
  45. data/lib/backup/record/sftp.rb +38 -0
  46. data/lib/backup/storage/ftp.rb +38 -0
  47. data/lib/backup/storage/local.rb +24 -0
  48. data/lib/backup/storage/s3.rb +16 -0
  49. data/lib/backup/storage/scp.rb +30 -0
  50. data/lib/backup/storage/sftp.rb +31 -0
  51. data/setup/backup.rb +202 -0
  52. data/setup/backup.sqlite3 +0 -0
  53. data/spec/configuration/attributes_spec.rb +35 -0
  54. metadata +183 -0
@@ -0,0 +1,24 @@
1
+ module Backup
2
+ module Storage
3
+ class Local
4
+
5
+ include Backup::CommandHelper
6
+
7
+ # Store on same machine, preferentially in a different hard drive or in
8
+ # a mounted network path (NFS, Samba, etc)
9
+ attr_accessor :path, :tmp_path, :final_file
10
+
11
+ # Stores the backup file on local machine
12
+ def initialize(adapter)
13
+ self.path = adapter.procedure.get_storage_configuration.attributes['path']
14
+ self.tmp_path = adapter.tmp_path
15
+ self.final_file = adapter.final_file
16
+
17
+ run "mkdir -p #{path}"
18
+ run "cp #{File.join(tmp_path, final_file).gsub('\ ', ' ')} #{File.join(path, final_file)}"
19
+ end
20
+
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,16 @@
1
+ require 'backup/connection/s3'
2
+
3
+ module Backup
4
+ module Storage
5
+ class S3
6
+
7
+ # Stores the backup file on the remote server using S3
8
+ def initialize(adapter)
9
+ s3 = Backup::Connection::S3.new(adapter)
10
+ s3.connect
11
+ s3.store
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,30 @@
1
+ require 'net/scp'
2
+
3
+ module Backup
4
+ module Storage
5
+ class SCP
6
+
7
+ attr_accessor :user, :password, :ip, :path, :tmp_path, :final_file
8
+
9
+ # Stores the backup file on the remote server using SCP
10
+ def initialize(adapter)
11
+ %w(ip user password path).each do |method|
12
+ send("#{method}=", adapter.procedure.get_storage_configuration.attributes[method])
13
+ end
14
+
15
+ final_file = adapter.final_file
16
+ tmp_path = adapter.tmp_path
17
+
18
+ Net::SSH.start(ip, user, :password => password) do |ssh|
19
+ ssh.exec "mkdir -p #{path}"
20
+ end
21
+
22
+ puts "Storing \"#{final_file}\" to path \"#{path}\" on remote server (#{ip})."
23
+ Net::SCP.start(ip, user, :password => password) do |scp|
24
+ scp.upload! File.join(tmp_path, final_file).gsub('\ ', ' '), path
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ require 'net/sftp'
2
+
3
+ module Backup
4
+ module Storage
5
+ class SFTP
6
+
7
+ attr_accessor :user, :password, :ip, :path, :tmp_path, :final_file
8
+
9
+ # Stores the backup file on the remote server using SFTP
10
+ def initialize(adapter)
11
+ %w(ip user password path).each do |method|
12
+ send("#{method}=", adapter.procedure.get_storage_configuration.attributes[method])
13
+ end
14
+
15
+ final_file = adapter.final_file
16
+ tmp_path = adapter.tmp_path
17
+
18
+ Net::SFTP.start(ip, user, :password => password) do |sftp|
19
+ begin
20
+ puts "Storing \"#{final_file}\" to path \"#{path}\" on remote server (#{ip})."
21
+ sftp.upload!(File.join(tmp_path, final_file).gsub('\ ', ' '), File.join(path, final_file))
22
+ rescue
23
+ puts "Could not find \"#{path}\" on \"#{ip}\", please ensure this directory exists."
24
+ exit
25
+ end
26
+ end
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,202 @@
1
+ # Backup Configuration File
2
+ #
3
+ # Use the "backup" block to add backup settings to the configuration file.
4
+ # The argument before the "do" in (backup "argument" do) is called a "trigger".
5
+ # This acts as the identifier for the configuration.
6
+ #
7
+ # In the example below we have a "mysql-backup-s3" trigger for the backup setting.
8
+ # All the configuration is done inside this block. To initialize the backup process for this block,
9
+ # you invoke it using the following command:
10
+ #
11
+ # backup --run mysql-backup-s3
12
+ #
13
+ # You can add as many backup block settings as you want, just be sure every trigger is unique and you can run
14
+ # each of them separately.
15
+ #
16
+ # ADAPTERS
17
+ # - MySQL
18
+ # - PostgreSQL
19
+ # - SQLite
20
+ # - Archive
21
+ # - Custom
22
+ #
23
+ # STORAGE METHODS
24
+ # - S3 (Amazon)
25
+ # - SCP (Remote Server)
26
+ # - FTP (Remote Server)
27
+ # - SFTP (Remote Server)
28
+ # - LOCAL (Local Server)
29
+ #
30
+ # GLOBAL OPTIONS
31
+ # - Keep Backups (keep_backups)
32
+ # - Encrypt With Pasword (encrypt_with_password)
33
+ # - Notify (notify)
34
+ #
35
+ # This is the "decrypt" command for all encrypted backups:
36
+ # sudo backup --decrypt /path/to/encrypted/file
37
+ #
38
+ # Each Backup Setting can contain:
39
+ # - 1 Adapter
40
+ # - 1 Storage Method
41
+ # - Multiple Global Options
42
+ #
43
+ # The combination of these, however, do not matter! So experiment with it.
44
+ #
45
+ # You can also let Backup notify you by email on successfully created backups.
46
+ # - Just uncomment the block of code below (notifier_settings) and fill in your credentials.
47
+ # - Then for set "notify" to "true" in each (backup) block you wish to be notified of.
48
+ #
49
+ # For more information on "Backup", please refer to the wiki on github
50
+ # http://wiki.github.com/meskyanichi/backup/configuration-file
51
+
52
+
53
+ # Notifier
54
+ # Uncomment this if you want to enable notification by email on successful backup runs
55
+ # You will also have to set "notify true" inside each backup block below to enable it for that particular backup
56
+ # notifier_settings do
57
+ #
58
+ # to "example1@gmail.com"
59
+ # from "example2@gmail.com"
60
+ #
61
+ # smtp do
62
+ # host "smtp.gmail.com"
63
+ # port "587"
64
+ # username "example1@gmail.com"
65
+ # password "example1password"
66
+ # authentication "plain"
67
+ # domain "localhost.localdomain"
68
+ # tls true
69
+ # end
70
+ #
71
+ # end
72
+
73
+
74
+ # Initialize with:
75
+ # sudo backup --run mysql-backup-s3
76
+ backup 'mysql-backup-s3' do
77
+
78
+ adapter :mysql do
79
+ user 'user'
80
+ password 'password'
81
+ database 'database'
82
+
83
+ # skip_tables ['table1', 'table2', 'table3']
84
+ #
85
+ # options do
86
+ # host '123.45.678.90'
87
+ # port '80'
88
+ # socket '/tmp/socket.sock'
89
+ # end
90
+ # additional_options '--single-transaction --quick'
91
+ end
92
+
93
+ storage :s3 do
94
+ access_key_id 'access_key_id'
95
+ secret_access_key 'secret_access_key'
96
+ bucket '/bucket/backups/mysql/'
97
+ use_ssl true
98
+ end
99
+
100
+ keep_backups 25
101
+ encrypt_with_password 'password'
102
+ notify false
103
+
104
+ end
105
+
106
+
107
+ # Initialize with:
108
+ # sudo backup --run postgresql-backup-s3
109
+ backup 'postgresql-backup-scp' do
110
+
111
+ adapter :postgresql do
112
+ user 'user'
113
+ database 'database'
114
+
115
+ # skip_tables ['table1', 'table2', 'table3']
116
+
117
+ # options do
118
+ # host '123.45.678.90'
119
+ # port '80'
120
+ # socket '/tmp/socket.sock'
121
+ # end
122
+ # additional_options '--clean --blobs'
123
+ end
124
+
125
+ storage :scp do
126
+ ip 'example.com'
127
+ user 'user'
128
+ password 'password'
129
+ path '/var/backups/postgresql/'
130
+ end
131
+
132
+ keep_backups :all
133
+ encrypt_with_password false
134
+ notify false
135
+
136
+ end
137
+
138
+
139
+ # Initialize with:
140
+ # sudo backup --run archive-backup-ftp
141
+ backup 'archive-backup-ftp' do
142
+
143
+ adapter :archive do
144
+ files ["/path/to/log", "/path/to/db"]
145
+ end
146
+
147
+ storage :ftp do
148
+ ip 'example.com'
149
+ user 'user'
150
+ password 'password'
151
+ path '/var/backups/archive/'
152
+ end
153
+
154
+ keep_backups 10
155
+ encrypt_with_password false
156
+ notify false
157
+
158
+ end
159
+
160
+
161
+ # Initialize with:
162
+ # sudo backup --run custom-backup-sftp
163
+ backup 'custom-backup-sftp' do
164
+
165
+ adapter :custom do
166
+ commands \
167
+ [ "mysqldump [options] [database] > :tmp_path/my_mysql_dump.sql",
168
+ "pg_dump [options] [database] > :tmp_path/my_postgresql_dump.sql",
169
+ "any_other_db_format [options] [database] > :tmp_path/my_any_other_db_format.sql" ]
170
+ end
171
+
172
+ storage :sftp do
173
+ ip 'example.com'
174
+ user 'user'
175
+ password 'password'
176
+ path '/var/backups/custom/'
177
+ end
178
+
179
+ keep_backups :all
180
+ encrypt_with_password 'password'
181
+ notify false
182
+
183
+ end
184
+
185
+
186
+ # Initializ with:
187
+ # sudo backup --run sqlite-backup-local
188
+ backup 'sqlite-backup-local' do
189
+
190
+ adapter :sqlite do
191
+ database "/path/to/database.sqlite3"
192
+ end
193
+
194
+ storage :local do
195
+ path "/path/to/storage/location/"
196
+ end
197
+
198
+ keep_backups :all
199
+ encrypt_with_password false
200
+ notify false
201
+
202
+ end
Binary file
@@ -0,0 +1,35 @@
1
+ require 'backup/configuration/attributes'
2
+
3
+ describe Backup::Configuration::Attributes do
4
+ before(:all) do
5
+ class ConfigurationSample
6
+ extend Backup::Configuration::Attributes
7
+ generate_attributes :file, :username, :password
8
+ end
9
+ @sample = ConfigurationSample.new
10
+ end
11
+
12
+ it "should generate setter methods to attributes" do
13
+ @sample.should respond_to(:file)
14
+ @sample.should respond_to(:username)
15
+ @sample.should respond_to(:password)
16
+ end
17
+
18
+ it "should generate accessor for attributes" do
19
+ @sample.should respond_to(:attributes)
20
+ end
21
+
22
+ it "should store keys of attributes as strings" do
23
+ @sample.file "list.txt"
24
+ @sample.username "jonh"
25
+ @sample.password "secret"
26
+ @sample.attributes.keys.all? {|k| k.is_a?(String)}.should == true
27
+ end
28
+
29
+ it "should store values of attributes in attributes hash" do
30
+ @sample.file "list.txt"
31
+ @sample.attributes.keys.should include('file')
32
+ @sample.attributes['file'].should == "list.txt"
33
+ end
34
+ end
35
+
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: backup-wakiki
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 4
9
+ - 1
10
+ version: 2.4.1
11
+ platform: ruby
12
+ authors:
13
+ - Michael van Rooijen
14
+ - "Fernando Migliorini Luiz\xC3\xA3o"
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2010-06-25 00:00:00 +01:00
20
+ default_executable: backup
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: activerecord
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 9
31
+ segments:
32
+ - 2
33
+ - 3
34
+ - 5
35
+ version: 2.3.5
36
+ type: :runtime
37
+ version_requirements: *id001
38
+ - !ruby/object:Gem::Dependency
39
+ name: sqlite3-ruby
40
+ prerelease: false
41
+ requirement: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 21
47
+ segments:
48
+ - 1
49
+ - 2
50
+ - 5
51
+ version: 1.2.5
52
+ type: :runtime
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
55
+ name: hirb
56
+ prerelease: false
57
+ requirement: &id003 !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 5
63
+ segments:
64
+ - 0
65
+ - 2
66
+ - 9
67
+ version: 0.2.9
68
+ type: :runtime
69
+ version_requirements: *id003
70
+ - !ruby/object:Gem::Dependency
71
+ name: pony
72
+ prerelease: false
73
+ requirement: &id004 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ hash: 1
79
+ segments:
80
+ - 0
81
+ - 5
82
+ version: "0.5"
83
+ type: :runtime
84
+ version_requirements: *id004
85
+ description: "\n Backup is a Ruby Gem written for Unix and Rails environments. It can be used both with and without the\n Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases such as\n MySQL/PostgreSQL and Files/Folders. All backups can be transferred to Amazon S3 or any remote server you\n have access to, using either SCP, SFTP or regular FTP. Backup handles Compression, Archiving, Encryption,\n Backup Cleaning (Cycling) and supports Email Notifications.\n "
86
+ email: meskyanichi@gmail.com
87
+ executables:
88
+ - backup
89
+ extensions: []
90
+
91
+ extra_rdoc_files:
92
+ - LICENSE
93
+ - README.textile
94
+ files:
95
+ - .document
96
+ - .gitignore
97
+ - CHANGELOG
98
+ - LICENSE
99
+ - README.textile
100
+ - Rakefile
101
+ - VERSION
102
+ - backup-2.3.1.gem
103
+ - backup-wakiki.gemspec
104
+ - backup.gemspec
105
+ - bin/backup
106
+ - generators/backup/backup_generator.rb
107
+ - generators/backup/templates/config/backup.rb
108
+ - generators/backup/templates/migrations/create_backup_tables.rb
109
+ - generators/backup/templates/tasks/backup.rake
110
+ - generators/backup_update/backup_update_generator.rb
111
+ - generators/backup_update/templates/migrations/update_backup_tables.rb
112
+ - lib/backup.rb
113
+ - lib/backup/adapters/archive.rb
114
+ - lib/backup/adapters/base.rb
115
+ - lib/backup/adapters/custom.rb
116
+ - lib/backup/adapters/mysql.rb
117
+ - lib/backup/adapters/postgresql.rb
118
+ - lib/backup/adapters/sqlite.rb
119
+ - lib/backup/command_helper.rb
120
+ - lib/backup/configuration/adapter.rb
121
+ - lib/backup/configuration/adapter_options.rb
122
+ - lib/backup/configuration/attributes.rb
123
+ - lib/backup/configuration/base.rb
124
+ - lib/backup/configuration/helpers.rb
125
+ - lib/backup/configuration/mail.rb
126
+ - lib/backup/configuration/smtp.rb
127
+ - lib/backup/configuration/storage.rb
128
+ - lib/backup/connection/s3.rb
129
+ - lib/backup/environment/base.rb
130
+ - lib/backup/environment/rails.rb
131
+ - lib/backup/environment/unix.rb
132
+ - lib/backup/mail/base.rb
133
+ - lib/backup/mail/mail.txt
134
+ - lib/backup/record/base.rb
135
+ - lib/backup/record/ftp.rb
136
+ - lib/backup/record/local.rb
137
+ - lib/backup/record/s3.rb
138
+ - lib/backup/record/scp.rb
139
+ - lib/backup/record/sftp.rb
140
+ - lib/backup/storage/ftp.rb
141
+ - lib/backup/storage/local.rb
142
+ - lib/backup/storage/s3.rb
143
+ - lib/backup/storage/scp.rb
144
+ - lib/backup/storage/sftp.rb
145
+ - setup/backup.rb
146
+ - setup/backup.sqlite3
147
+ - spec/configuration/attributes_spec.rb
148
+ has_rdoc: true
149
+ homepage: http://final-creation.com/open-source
150
+ licenses: []
151
+
152
+ post_install_message:
153
+ rdoc_options:
154
+ - --charset=UTF-8
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ none: false
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ hash: 3
163
+ segments:
164
+ - 0
165
+ version: "0"
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ none: false
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ hash: 3
172
+ segments:
173
+ - 0
174
+ version: "0"
175
+ requirements: []
176
+
177
+ rubyforge_project:
178
+ rubygems_version: 1.3.7
179
+ signing_key:
180
+ specification_version: 3
181
+ summary: Backup is a Ruby Gem that simplifies making backups for databases, files and folders.
182
+ test_files:
183
+ - spec/configuration/attributes_spec.rb