backup 2.4.5.1 → 3.0.0.build.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/.gitignore +2 -0
  2. data/.infinity_test +7 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +17 -0
  5. data/Gemfile.lock +88 -0
  6. data/LICENSE.md +24 -0
  7. data/README.md +189 -75
  8. data/backup.gemspec +41 -0
  9. data/bin/backup +161 -90
  10. data/lib/backup.rb +133 -117
  11. data/lib/backup/archive.rb +54 -0
  12. data/lib/backup/cli.rb +50 -0
  13. data/lib/backup/compressor/base.rb +17 -0
  14. data/lib/backup/compressor/gzip.rb +61 -0
  15. data/lib/backup/configuration/base.rb +7 -67
  16. data/lib/backup/configuration/compressor/base.rb +10 -0
  17. data/lib/backup/configuration/compressor/gzip.rb +23 -0
  18. data/lib/backup/configuration/database/base.rb +18 -0
  19. data/lib/backup/configuration/database/mongodb.rb +37 -0
  20. data/lib/backup/configuration/database/mysql.rb +37 -0
  21. data/lib/backup/configuration/database/postgresql.rb +37 -0
  22. data/lib/backup/configuration/database/redis.rb +35 -0
  23. data/lib/backup/configuration/encryptor/base.rb +10 -0
  24. data/lib/backup/configuration/encryptor/gpg.rb +17 -0
  25. data/lib/backup/configuration/encryptor/open_ssl.rb +26 -0
  26. data/lib/backup/configuration/helpers.rb +47 -17
  27. data/lib/backup/configuration/notifier/base.rb +39 -0
  28. data/lib/backup/configuration/notifier/mail.rb +52 -0
  29. data/lib/backup/configuration/storage/base.rb +18 -0
  30. data/lib/backup/configuration/storage/cloudfiles.rb +21 -0
  31. data/lib/backup/configuration/storage/dropbox.rb +25 -0
  32. data/lib/backup/configuration/storage/ftp.rb +25 -0
  33. data/lib/backup/configuration/storage/rsync.rb +25 -0
  34. data/lib/backup/configuration/storage/s3.rb +25 -0
  35. data/lib/backup/configuration/storage/scp.rb +25 -0
  36. data/lib/backup/configuration/storage/sftp.rb +25 -0
  37. data/lib/backup/database/base.rb +33 -0
  38. data/lib/backup/database/mongodb.rb +137 -0
  39. data/lib/backup/database/mysql.rb +104 -0
  40. data/lib/backup/database/postgresql.rb +111 -0
  41. data/lib/backup/database/redis.rb +105 -0
  42. data/lib/backup/encryptor/base.rb +17 -0
  43. data/lib/backup/encryptor/gpg.rb +78 -0
  44. data/lib/backup/encryptor/open_ssl.rb +67 -0
  45. data/lib/backup/finder.rb +39 -0
  46. data/lib/backup/logger.rb +80 -0
  47. data/lib/backup/model.rb +249 -0
  48. data/lib/backup/notifier/base.rb +29 -0
  49. data/lib/backup/notifier/binder.rb +32 -0
  50. data/lib/backup/notifier/mail.rb +141 -0
  51. data/lib/backup/notifier/templates/notify_failure.erb +31 -0
  52. data/lib/backup/notifier/templates/notify_success.erb +16 -0
  53. data/lib/backup/storage/base.rb +60 -3
  54. data/lib/backup/storage/cloudfiles.rb +85 -6
  55. data/lib/backup/storage/dropbox.rb +74 -4
  56. data/lib/backup/storage/ftp.rb +103 -27
  57. data/lib/backup/storage/object.rb +45 -0
  58. data/lib/backup/storage/rsync.rb +100 -0
  59. data/lib/backup/storage/s3.rb +100 -7
  60. data/lib/backup/storage/scp.rb +94 -19
  61. data/lib/backup/storage/sftp.rb +94 -19
  62. data/lib/backup/version.rb +70 -1
  63. data/lib/templates/archive +4 -0
  64. data/lib/templates/compressor/gzip +4 -0
  65. data/lib/templates/database/mongodb +10 -0
  66. data/lib/templates/database/mysql +11 -0
  67. data/lib/templates/database/postgresql +11 -0
  68. data/lib/templates/database/redis +10 -0
  69. data/lib/templates/encryptor/gpg +9 -0
  70. data/lib/templates/encryptor/openssl +5 -0
  71. data/lib/templates/notifier/mail +14 -0
  72. data/lib/templates/readme +15 -0
  73. data/lib/templates/storage/cloudfiles +7 -0
  74. data/lib/templates/storage/dropbox +8 -0
  75. data/lib/templates/storage/ftp +8 -0
  76. data/lib/templates/storage/rsync +7 -0
  77. data/lib/templates/storage/s3 +8 -0
  78. data/lib/templates/storage/scp +8 -0
  79. data/lib/templates/storage/sftp +8 -0
  80. data/spec/archive_spec.rb +53 -0
  81. data/spec/backup_spec.rb +11 -0
  82. data/spec/compressor/gzip_spec.rb +59 -0
  83. data/spec/configuration/base_spec.rb +35 -0
  84. data/spec/configuration/compressor/gzip_spec.rb +28 -0
  85. data/spec/configuration/database/base_spec.rb +16 -0
  86. data/spec/configuration/database/mongodb_spec.rb +30 -0
  87. data/spec/configuration/database/mysql_spec.rb +32 -0
  88. data/spec/configuration/database/postgresql_spec.rb +32 -0
  89. data/spec/configuration/database/redis_spec.rb +30 -0
  90. data/spec/configuration/encryptor/gpg_spec.rb +25 -0
  91. data/spec/configuration/encryptor/open_ssl_spec.rb +31 -0
  92. data/spec/configuration/notifier/mail_spec.rb +32 -0
  93. data/spec/configuration/storage/cloudfiles_spec.rb +34 -0
  94. data/spec/configuration/storage/dropbox_spec.rb +40 -0
  95. data/spec/configuration/storage/ftp_spec.rb +40 -0
  96. data/spec/configuration/storage/rsync_spec.rb +37 -0
  97. data/spec/configuration/storage/s3_spec.rb +37 -0
  98. data/spec/configuration/storage/scp_spec.rb +40 -0
  99. data/spec/configuration/storage/sftp_spec.rb +40 -0
  100. data/spec/database/base_spec.rb +30 -0
  101. data/spec/database/mongodb_spec.rb +144 -0
  102. data/spec/database/mysql_spec.rb +150 -0
  103. data/spec/database/postgresql_spec.rb +164 -0
  104. data/spec/database/redis_spec.rb +122 -0
  105. data/spec/encryptor/gpg_spec.rb +57 -0
  106. data/spec/encryptor/open_ssl_spec.rb +102 -0
  107. data/spec/logger_spec.rb +37 -0
  108. data/spec/model_spec.rb +236 -0
  109. data/spec/notifier/mail_spec.rb +97 -0
  110. data/spec/spec_helper.rb +21 -0
  111. data/spec/storage/base_spec.rb +33 -0
  112. data/spec/storage/cloudfiles_spec.rb +102 -0
  113. data/spec/storage/dropbox_spec.rb +89 -0
  114. data/spec/storage/ftp_spec.rb +133 -0
  115. data/spec/storage/object_spec.rb +74 -0
  116. data/spec/storage/rsync_spec.rb +115 -0
  117. data/spec/storage/s3_spec.rb +110 -0
  118. data/spec/storage/scp_spec.rb +129 -0
  119. data/spec/storage/sftp_spec.rb +125 -0
  120. data/spec/version_spec.rb +32 -0
  121. metadata +139 -123
  122. data/CHANGELOG +0 -131
  123. data/LICENSE +0 -20
  124. data/generators/backup/backup_generator.rb +0 -69
  125. data/generators/backup/templates/backup.rake +0 -56
  126. data/generators/backup/templates/backup.rb +0 -253
  127. data/generators/backup/templates/create_backup_tables.rb +0 -18
  128. data/generators/backup_update/backup_update_generator.rb +0 -50
  129. data/generators/backup_update/templates/migrations/update_backup_tables.rb +0 -27
  130. data/lib/backup/adapters/archive.rb +0 -34
  131. data/lib/backup/adapters/base.rb +0 -167
  132. data/lib/backup/adapters/custom.rb +0 -41
  133. data/lib/backup/adapters/mongo_db.rb +0 -139
  134. data/lib/backup/adapters/mysql.rb +0 -60
  135. data/lib/backup/adapters/postgresql.rb +0 -60
  136. data/lib/backup/adapters/sqlite.rb +0 -25
  137. data/lib/backup/command_helper.rb +0 -14
  138. data/lib/backup/configuration/adapter.rb +0 -21
  139. data/lib/backup/configuration/adapter_options.rb +0 -8
  140. data/lib/backup/configuration/attributes.rb +0 -19
  141. data/lib/backup/configuration/mail.rb +0 -20
  142. data/lib/backup/configuration/smtp.rb +0 -8
  143. data/lib/backup/configuration/storage.rb +0 -8
  144. data/lib/backup/connection/cloudfiles.rb +0 -75
  145. data/lib/backup/connection/dropbox.rb +0 -63
  146. data/lib/backup/connection/s3.rb +0 -88
  147. data/lib/backup/core_ext/object.rb +0 -5
  148. data/lib/backup/environment/base.rb +0 -12
  149. data/lib/backup/environment/rails_configuration.rb +0 -15
  150. data/lib/backup/environment/unix_configuration.rb +0 -109
  151. data/lib/backup/mail/base.rb +0 -97
  152. data/lib/backup/mail/mail.txt +0 -7
  153. data/lib/backup/record/base.rb +0 -65
  154. data/lib/backup/record/cloudfiles.rb +0 -28
  155. data/lib/backup/record/dropbox.rb +0 -27
  156. data/lib/backup/record/ftp.rb +0 -39
  157. data/lib/backup/record/local.rb +0 -26
  158. data/lib/backup/record/s3.rb +0 -25
  159. data/lib/backup/record/scp.rb +0 -33
  160. data/lib/backup/record/sftp.rb +0 -38
  161. data/lib/backup/storage/local.rb +0 -22
  162. data/lib/generators/backup/USAGE +0 -10
  163. data/lib/generators/backup/backup_generator.rb +0 -47
  164. data/lib/generators/backup/templates/backup.rake +0 -56
  165. data/lib/generators/backup/templates/backup.rb +0 -236
  166. data/lib/generators/backup/templates/create_backup_tables.rb +0 -18
  167. data/setup/backup.rb +0 -257
  168. data/setup/backup.sqlite3 +0 -0
@@ -0,0 +1,2 @@
1
+ .DS_Store
2
+ *.gem
@@ -0,0 +1,7 @@
1
+ infinity_test do
2
+ heuristics do
3
+ add('lib/') do |file|
4
+ run :all => :tests
5
+ end
6
+ end
7
+ end
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format Fuubar
2
+ --color
3
+ --tty
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ ##
2
+ # RubyGems Source
3
+ source 'http://rubygems.org'
4
+
5
+ ##
6
+ # Bundle gems definde inside the gemspec file
7
+ gemspec
8
+
9
+ ##
10
+ # Define gems to be used in the 'test' environment
11
+ group :test do
12
+ gem 'rspec'
13
+ gem 'mocha'
14
+ gem 'infinity_test'
15
+ gem 'fuubar'
16
+ gem 'timecop'
17
+ end
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ backup (3.0.0.build.0)
5
+ dropbox (~> 1.2.3)
6
+ fog (~> 0.5.3)
7
+ mail (~> 2.2.15)
8
+ net-scp (~> 1.0.4)
9
+ net-sftp (~> 2.0.5)
10
+ thor (~> 0.14.6)
11
+
12
+ GEM
13
+ remote: http://rubygems.org/
14
+ specs:
15
+ activesupport (3.0.5)
16
+ builder (3.0.0)
17
+ diff-lcs (1.1.2)
18
+ dropbox (1.2.3)
19
+ json (>= 1.2.0)
20
+ mechanize (>= 1.0.0)
21
+ multipart-post (>= 1.0)
22
+ oauth (>= 0.3.6)
23
+ excon (0.5.6)
24
+ fog (0.5.3)
25
+ builder
26
+ excon (>= 0.5.2)
27
+ formatador (>= 0.0.16)
28
+ json
29
+ mime-types
30
+ net-ssh (>= 2.0.23)
31
+ nokogiri (>= 1.4.4)
32
+ ruby-hmac
33
+ formatador (0.0.16)
34
+ fuubar (0.0.3)
35
+ rspec (~> 2.0)
36
+ rspec-instafail (~> 0.1.4)
37
+ ruby-progressbar (~> 0.0.9)
38
+ i18n (0.5.0)
39
+ infinity_test (1.0.2)
40
+ notifiers (>= 1.1.0)
41
+ watchr (>= 0.7)
42
+ json (1.5.1)
43
+ mail (2.2.15)
44
+ activesupport (>= 2.3.6)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mechanize (1.0.0)
49
+ nokogiri (>= 1.2.1)
50
+ mime-types (1.16)
51
+ mocha (0.9.12)
52
+ multipart-post (1.1.0)
53
+ net-scp (1.0.4)
54
+ net-ssh (>= 1.99.1)
55
+ net-sftp (2.0.5)
56
+ net-ssh (>= 2.0.9)
57
+ net-ssh (2.1.3)
58
+ nokogiri (1.4.4)
59
+ notifiers (1.1.0)
60
+ oauth (0.4.4)
61
+ polyglot (0.3.1)
62
+ rspec (2.5.0)
63
+ rspec-core (~> 2.5.0)
64
+ rspec-expectations (~> 2.5.0)
65
+ rspec-mocks (~> 2.5.0)
66
+ rspec-core (2.5.1)
67
+ rspec-expectations (2.5.0)
68
+ diff-lcs (~> 1.1.2)
69
+ rspec-instafail (0.1.6)
70
+ rspec-mocks (2.5.0)
71
+ ruby-hmac (0.4.0)
72
+ ruby-progressbar (0.0.9)
73
+ thor (0.14.6)
74
+ timecop (0.3.5)
75
+ treetop (1.4.9)
76
+ polyglot (>= 0.3.1)
77
+ watchr (0.7)
78
+
79
+ PLATFORMS
80
+ ruby
81
+
82
+ DEPENDENCIES
83
+ backup!
84
+ fuubar
85
+ infinity_test
86
+ mocha
87
+ rspec
88
+ timecop
@@ -0,0 +1,24 @@
1
+
2
+ Copyright (c) 2009-2011 Michael van Rooijen ( [@meskyanichi](http://twitter.com/#!/meskyanichi) )
3
+ =================================================================================================
4
+
5
+ The "Backup" RubyGem is released under the **MIT LICENSE**
6
+ ----------------------------------------------------------
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,122 +1,236 @@
1
- # Backup
1
+ Backup 3
2
+ ========
2
3
 
3
- ## A Backup Ruby Gem
4
+ Backup is a RubyGem (for UNIX-like operating systems: Linux, Mac OSX) that allows you to configure and perform backups in a simple manner using an elegant Ruby DSL. It supports various various databases (MySQL, PostgreSQL, MongoDB and Redis), it supports various storage locations (Amazon S3, Rackspace Cloud Files, Dropbox, any remote server through FTP, SFTP, SCP and RSync), it can archive files and folders, it can cycle backups, it can do incremental backups, it can compress backups, it can encrypt backups (OpenSSL or GPG), it can notify you about successful and/or failed backups. It is very extensible and easy to add new functionality to. It's easy to use.
4
5
 
5
- __Backup__ is a Ruby Gem written for __Unix__ and __Ruby on Rails (2 and 3)__ environments. It can be used both with and without the Ruby on Rails framework! This gem offers a quick and simple solution to backing up databases such as MySQL/PostgreSQL/SQLite and Files/Folders. All backups can be transferred to Amazon S3, Rackspace Cloud Files, Dropbox Web Service, any remote server you have access to (using either SCP, SFTP or regular FTP), or a Local server. Backup handles Compression, Archiving, Encryption, Backup Cleaning (Cycling) and supports Email Notifications.
6
+ Author
7
+ ------
6
8
 
7
- ## Written for Environments
9
+ Michael van Rooijen ( [@meskyanichi](http://twitter.com/#!/meskyanichi) )
8
10
 
9
- * UNIX (Ubuntu, OSX, etc.)
10
- * Ruby on Rails 3
11
- * Ruby on Rails 2
11
+ Drop me a message for any questions, suggestions, requests, bugs or submit them to the [issue log](https://github.com/meskyanichi/backup/issues).
12
12
 
13
- ## Authors/Maintainers
13
+ Installation
14
+ ------------
14
15
 
15
- * [Meskyanichi - Michael van Rooijen](http://github.com/meskyanichi)
16
- * [Fernandoluizao - Fernando Migliorini Luizão](http://github.com/fernandoluizao)
16
+ To get the latest stable version
17
17
 
18
- ### Contributors
18
+ gem install backup
19
19
 
20
- * [dtrueman](http://github.com/dtrueman)
21
- * [Nathan L Smith](http://github.com/smith)
22
- * [Francesc Esplugas](http://github.com/fesplugas)
23
- * [wakiki](http://github.com/wakiki)
24
- * [Dan Hixon](http://github.com/danhixon)
25
- * [Adam Greene](http://github.com/skippy)
26
- * [Dmitriy Novotochinov](http://github.com/trybeee)
20
+ To get the latest *build* of the latest stable version
27
21
 
22
+ gem install backup --pre
28
23
 
29
- ## Backup's Current Capabilities
24
+ Builds **aim** to be stable, but cannot guarantee it. Builds tend to be released a lot more frequent than the stable versions. So if you want to live on the edge and want the latest improvements, install the build gems.
30
25
 
31
- ### Storage Methods
26
+ You can view the list of released versions over at [RubyGems.org (Backup)](https://rubygems.org/gems/backup/versions)
32
27
 
33
- * Amazon S3
34
- * Rackspace Cloud Files
35
- * Dropbox (Using your API key/secret from developers.dropbox.com)
36
- * Remote Server (Available Protocols: SCP, SFTP, FTP)
37
- * Local server (Example Locations: Another Hard Drive, Network path)
38
28
 
39
- ### Adapters
29
+ What Backup 3 currently supports
30
+ ================================
40
31
 
41
- * MySQL
42
- * PostgreSQL
43
- * SQLite
44
- * MongoDB
45
- * Archive (Any files and/or folders)
46
- * Custom (Anything you can produce using the command line)
32
+ **Below you find a summary of what the Backup gem currently supports. Each of the items below is more or less isolated from each other, meaning that adding new databases, storage locations, compressors, encryptors, notifiers, and such is relatively easy to do.**
47
33
 
48
- ### Archiving
34
+ Database Support
35
+ ----------------
49
36
 
50
- Handles archiving for the __Archive__ and __Custom__ adapters.
37
+ - MySQL
38
+ - PostgreSQL
39
+ - MongoDB
40
+ - Redis
51
41
 
52
- ### Encryption
42
+ [Database Wiki Page](https://github.com/meskyanichi/backup/wiki/Databases)
53
43
 
54
- Handles encryption of __all__ backups for __any__ adapter.
55
- To decrypt a "Backup encrypted file" you can use Backup's built-in utility command:
44
+ Filesystem Support
45
+ ------------------
56
46
 
57
- sudo backup --decrypt /path/to/encrypted/file.enc
47
+ - Files
48
+ - Folders
58
49
 
59
- ### Backup Cleaning
50
+ [Archive Wiki Page](https://github.com/meskyanichi/backup/wiki/Archives)
60
51
 
61
- With Backup you can very easily specify how many backups you would like to have stored (per backup procedure!) on your Amazon S3, Remote or Local server. When the limit you specify gets exceeded, the oldest backup will automatically be cleaned up.
52
+ Storage Locations
53
+ -----------------
62
54
 
63
- ### Email Notifications
55
+ - Amazon Simple Storage Service (S3)
56
+ - Rackspace Cloud Files (Mosso)
57
+ - Dropbox
58
+ - Remote Servers *(Available Protocols: FTP, SFTP, SCP and RSync)*
64
59
 
65
- You will be able to specify whether you would like to be notified by email when a backup successfully been stored. Simply fill in the email configuration block and set "notify" to true inside the backup procedure you would like to be notified of.
60
+ [Storage Wiki Page](https://github.com/meskyanichi/backup/wiki/Storages)
66
61
 
67
- ### Quick Example of a Single Backup Setting/Procedure inside the Backup Configuration File
62
+ Storage Features
63
+ ----------------
68
64
 
69
- backup 'mysql-backup-s3' do
70
- adapter :mysql do
71
- user 'user'
72
- password 'password'
73
- database 'database'
65
+ - Backup Cycling, applies to:
66
+ - Amazon Simple Storage Service (S3)
67
+ - Rackspace Cloud Files (Mosso)
68
+ - Dropbox
69
+ - Remote Servers *(Only Protocols: FTP, SFTP, SCP)*
70
+ - Incremental Backups, applies to:
71
+ - Remote Servers *(Only Protocols: RSync)*
72
+
73
+ [Storage Wiki Page](https://github.com/meskyanichi/backup/wiki/Storages)
74
+
75
+ Compressors
76
+ -----------
77
+
78
+ - Gzip
79
+
80
+ [Compressors Wiki Page](https://github.com/meskyanichi/backup/wiki/Compressors)
81
+
82
+ Encryptors
83
+ ----------
84
+
85
+ - OpenSSL
86
+ - GPG
87
+
88
+ [Encryptors Wiki Page](https://github.com/meskyanichi/backup/wiki/Encryptors)
89
+
90
+ Notifiers
91
+ ---------
92
+
93
+ - Mail
94
+
95
+ [Notifiers Wiki Page](https://github.com/meskyanichi/backup/wiki/Notifiers)
96
+
97
+ Supported Ruby versions (Tested with RSpec)
98
+ -------------------------------------------
99
+
100
+ - Ruby 1.9.2
101
+ - Ruby 1.8.7
102
+ - Ruby Enterprise Edition 1.8.7
103
+
104
+ Environments
105
+ ------------
106
+
107
+ Backup **3** runs in **UNIX**-based operating systems: Linux, Mac OSX, etc. It does **NOT** run on the Windows operating system, and there are currently no plans to support it.
108
+
109
+ Compatibility
110
+ -------------
111
+
112
+ Backup **3** is **NOT** backwards compatible with Backup **2**. The command line interface has changed. The DSL has changed. And a lot more has changed. All for the better.
113
+
114
+
115
+ A sample "Backup" configuration file
116
+ ====================================
117
+
118
+ Below you see a sample configuration file you could create for Backup 3. Just read through it slowly and I'm quite sure you will already know what's going to happen before I explain it to you. **(see explanation after the example)**
119
+
120
+ Backup::Model.new(:sample_backup, 'A sample backup configuration') do
121
+
122
+ database MySQL do |database|
123
+ database.name = 'my_sample_mysql_db'
124
+ database.username = 'my_username'
125
+ database.password = 'my_password'
126
+ database.skip_tables = ['logs']
127
+ database.additional_options = ['--single-transaction', '--quick']
128
+ end
129
+
130
+ database MongoDB do |database|
131
+ database.name = 'my_sample_mongo_db'
132
+ database.only_collections = ['users', 'events', 'posts']
74
133
  end
75
- storage :s3 do
76
- access_key_id 'access_key_id'
77
- secret_access_key 'secret_access_key'
78
- host 's3-ap-southeast-1.amazonaws.com'
79
- bucket '/bucket/backups/mysql/'
80
- use_ssl true
134
+
135
+ archive :user_avatars do |archive|
136
+ archive.add '/var/apps/my_sample_app/public/avatars'
137
+ end
138
+
139
+ archive :logs do |archive|
140
+ archive.add '/var/apps/my_sample_app/logs/production.log'
141
+ archive.add '/var/apps/my_sample_app/logs/newrelic_agent.log'
142
+ archive.add '/var/apps/my_sample_app/logs/other.log'
143
+ end
144
+
145
+ encrypt_with OpenSSL do |encryption|
146
+ encryption.password = 'my_secret_password'
147
+ end
148
+
149
+ compress_with Gzip do |compression|
150
+ compression.best = true
151
+ end
152
+
153
+ store_with S3 do |s3|
154
+ s3.access_key_id = 'my_access_key_id'
155
+ s3.secret_access_key = 'my_secret_access_key'
156
+ s3.region = 'us-east-1'
157
+ s3.bucket = 'my_bucket/backups'
158
+ s3.keep = 20
159
+ end
160
+
161
+ store_with RSync do |server|
162
+ server.username = 'my_username'
163
+ server.password = 'my_password'
164
+ server.ip = '123.45.678.90'
165
+ server.path = '~/backups/'
166
+ end
167
+
168
+ notify_by Mail do |mail|
169
+ mail.on_success = false
170
+ mail.on_failure = true
81
171
  end
82
- keep_backups 25
83
- encrypt_with_password 'my_password'
84
- notify true
85
172
  end
86
-
87
- Everything above should be pretty straightforward, so now, using the __trigger__ we specified between
88
- the `backup` and `do` you can execute this backup procedure like so:
89
173
 
90
- __Rails Environment__
174
+ ### Explanation for the above example
175
+
176
+ First it dumps all the tables inside the MySQL database "my_sample_mysql_db", except for the "logs" table. It also dumps the MongoDB database "my_sample_mongo_db", but only the collections "users", "events" and "posts". After that it'll create a "user_avatars.tar" archive with all the uploaded avatars of the users. After that it'll create a "logs.tar" archive with the "production.log", "newrelic_agent.log" and "other.log" logs. After that it'll encrypt the whole backup file (everything included: databases, archives) using "OpenSSL". Now the Backup can only be extracted when you know the password to decrypt it ("my_secret_password" in this case). After that it'll compress the backup file using Gzip (with the mode set to "best", rather than "fast" for best compression). Then it'll store the backup file to Amazon S3 in to 'my_bucket/backups'. Next it'll also transfer a copy of the backup file to a remote server using the RSync protocol, and it'll be stored in to the "$HOME/backups/" path on this server. Finally, it'll notify me by email if the backup raises an error/exception during the process indicating that something went wrong. (When setting `mail.on_success = true` it'll also notify you of every successful backup)
177
+
178
+ ### Things to note
179
+
180
+ The __keep__ option I passed in to the S3 storage location enables "Backup Cycling". In this case, after the 21st backup file gets pushed, it'll exceed the 20 backup limit, and remove the oldest backup from the S3 bucket.
181
+
182
+ The __RSync__ protocol doesn't utilize the __keep__ option. RSync is used to do incremental backups, and only stores a single file on your remote server, which gets incrementally updated with each run. For example, if everything you dump ends up to be about 2000MB, the first time, you'll be transferring the full 2000MB. If by the time the next backup run starts this dump has increased to 2100MB, it'll calculate the difference between the source and destination file and only transfer the remaining 100MB, rather than the full 2100MB. (Note: To reduce bandwidth as much as possible with RSync, ensure you don't use compression or encryption, otherwise RSync isn't able to calculate the difference very well and bandwidth usage greatly increases.)
183
+
184
+ The __Mail__ notifier. I have not provided the SMTP options to use my Gmail account to notify myself when exceptions are raised during the process. So this won't work, check out the wiki on how to configure this. I left it out in this example.
91
185
 
92
- rake backup:run trigger=mysql-backup-s3
186
+ ### And that's it!
93
187
 
94
- __Unix Environment__
188
+ So as you can see the DSL is straightforward and should be simple to understand and extend to your needs. You can have as many databases, archives, storage locations, compressors, encryptors and notifiers inside the above example as you need and it'll bundle all of it up in a nice packaged archive and transfer it to every specified location (as redundant as you like).
95
189
 
96
- sudo backup --run mysql-backup-s3
190
+ ### Running the example
97
191
 
98
- That's it. This was a simple example of how it works.
192
+ Remember the `Backup::Model.new(:sample_backup, 'A sample backup configuration') do`?
193
+ The `:sample_backup` is called the "id", or "trigger". This is used to identify the backup procedure/file and initialize it.
99
194
 
100
- ## Want to take Backup for a spin?
195
+ backup perform -t sample_backup
196
+
197
+ That's it.
198
+
199
+ ### Automatic backups
200
+
201
+ Since it's a simple command line utility, just write a cron to invoke it whenever you want. I recommend you use the [Whenever Gem](https://github.com/javan/whenever) to manage your cron tasks. It'll enable you to write such elegant automatic backup syntax in Ruby:
202
+
203
+ every 6.hours do
204
+ command "backup perform -t sample_backup"
205
+ end
101
206
 
102
- ### Wiki Pages
103
207
 
104
- [Check out our (15) helpful wiki pages](http://github.com/meskyanichi/backup/wiki)
208
+ Documentation
209
+ -------------
105
210
 
211
+ See the [Wiki Pages](https://github.com/meskyanichi/backup/wiki). The subjects labeled **without** the "Backup 2)"-prefix are meant for Backup 3 users.
106
212
 
107
- ### Requests
108
213
 
109
- If anyone has any requests, please send us a message or post it in the [issue log](http://github.com/meskyanichi/backup/issues)!
214
+ Suggestions, Bugs, Requests, Questions
215
+ --------------------------------------
110
216
 
217
+ View the [issue log](https://github.com/meskyanichi/backup/issues) and post them there.
111
218
 
112
- ### Suggestions?
113
219
 
114
- Send us a message! Fork the project!
220
+ Want to contribute?
221
+ -------------------
115
222
 
223
+ - Fork/Clone the **develop** branch
224
+ - Write RSpec tests, and test against:
225
+ - Ruby 1.9.2
226
+ - Ruby 1.8.7
227
+ - Ruby Enterprise Edition 1.8.7
228
+ - Try to keep the overall *structure / design* of the gem the same
116
229
 
117
- ### Found a Bug?
230
+ I can't guarantee I'll pull every pull request. Also, I may accept your pull request and drastically change parts to improve readability/maintainability. Feel free to discuss about improvements, new functionality/features in the [issue log](https://github.com/meskyanichi/backup/issues) before contributing if you need/want more information.
118
231
 
119
- [Report it](http://github.com/meskyanichi/backup/issues)
120
232
 
233
+ Backup 2 - Issues, Wiki, Source, Gems
234
+ =====================================
121
235
 
122
- __Michael van Rooijen | Final Creation. ([http://michaelvanrooijen.com/](http://michaelvanrooijen.com))__
236
+ I won't actively support Backup 2 anymore. The source will remain on [a separate branch](https://github.com/meskyanichi/backup/tree/backup-2). [The Issues](https://github.com/meskyanichi/backup/issues) that belong to Backup 2 have been tagged with a black label "Backup 2". The Backup 2 specific [Wiki pages](https://github.com/meskyanichi/backup/wiki) have been prefixed with "Backup 2) <Article>". [The Backup 2 Gems](http://rubygems.org/gems/backup) will always remain so you can still use Backup 2. I might still accept pull requests, but would highly encourage anyone to [move to __Backup 3__ once it's here](https://github.com/meskyanichi/backup).