backup 3.0.15 → 3.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -2
- data/Gemfile.lock +21 -10
- data/Guardfile +17 -0
- data/README.md +87 -42
- data/backup.gemspec +1 -9
- data/lib/backup.rb +6 -2
- data/lib/backup/archive.rb +1 -1
- data/lib/backup/cli.rb +1 -1
- data/lib/backup/compressor/bzip2.rb +64 -0
- data/lib/backup/configuration/compressor/bzip2.rb +23 -0
- data/lib/backup/configuration/notifier/presently.rb +25 -0
- data/lib/backup/encryptor/gpg.rb +1 -1
- data/lib/backup/notifier/presently.rb +105 -0
- data/lib/backup/storage/s3.rb +2 -6
- data/lib/backup/syncer/s3.rb +6 -4
- data/lib/backup/version.rb +1 -1
- data/lib/templates/archive +3 -0
- data/lib/templates/compressor/bzip2 +7 -0
- data/lib/templates/compressor/gzip +3 -0
- data/lib/templates/database/mongodb +3 -0
- data/lib/templates/database/mysql +3 -0
- data/lib/templates/database/postgresql +4 -1
- data/lib/templates/database/redis +3 -0
- data/lib/templates/encryptor/gpg +3 -0
- data/lib/templates/encryptor/openssl +3 -0
- data/lib/templates/notifier/campfire +3 -0
- data/lib/templates/notifier/mail +3 -0
- data/lib/templates/notifier/presently +12 -0
- data/lib/templates/notifier/twitter +3 -0
- data/lib/templates/readme +1 -1
- data/lib/templates/storage/cloudfiles +3 -0
- data/lib/templates/storage/dropbox +3 -0
- data/lib/templates/storage/ftp +3 -0
- data/lib/templates/storage/rsync +3 -0
- data/lib/templates/storage/s3 +14 -1
- data/lib/templates/storage/scp +3 -0
- data/lib/templates/storage/sftp +3 -0
- data/lib/templates/syncer/rsync +3 -0
- data/lib/templates/syncer/s3 +3 -0
- data/spec/archive_spec.rb +4 -4
- data/spec/compressor/bzip2_spec.rb +59 -0
- data/spec/encryptor/gpg_spec.rb +10 -10
- data/spec/notifier/presently_spec.rb +99 -0
- data/spec/spec_helper.rb +4 -0
- metadata +15 -7
- data/.infinity_test +0 -7
- data/.rspec +0 -3
data/Gemfile
CHANGED
@@ -19,7 +19,13 @@ end
|
|
19
19
|
group :test do
|
20
20
|
gem 'rspec'
|
21
21
|
gem 'mocha'
|
22
|
-
gem 'infinity_test'
|
23
|
-
gem 'fuubar'
|
24
22
|
gem 'timecop'
|
23
|
+
gem 'fuubar'
|
24
|
+
|
25
|
+
gem 'guard'
|
26
|
+
gem 'guard-rspec'
|
27
|
+
gem 'rb-fsevent' # guard notifications for osx
|
28
|
+
gem 'growl' # $ brew install growlnotify
|
29
|
+
gem 'rb-inotify' # guard notifications for linux
|
30
|
+
gem 'libnotify' # $ apt-get install ???
|
25
31
|
end
|
data/Gemfile.lock
CHANGED
@@ -18,6 +18,7 @@ GEM
|
|
18
18
|
rack (< 2, >= 1.1.0)
|
19
19
|
faraday_middleware (0.3.2)
|
20
20
|
faraday (~> 0.5.4)
|
21
|
+
ffi (1.0.9)
|
21
22
|
fog (0.7.0)
|
22
23
|
builder
|
23
24
|
excon (>= 0.5.5)
|
@@ -28,18 +29,21 @@ GEM
|
|
28
29
|
nokogiri (>= 1.4.4)
|
29
30
|
ruby-hmac
|
30
31
|
formatador (0.1.1)
|
31
|
-
fuubar (0.0.
|
32
|
+
fuubar (0.0.5)
|
32
33
|
rspec (~> 2.0)
|
33
34
|
rspec-instafail (~> 0.1.4)
|
34
|
-
ruby-progressbar (~> 0.0.
|
35
|
+
ruby-progressbar (~> 0.0.10)
|
36
|
+
growl (1.0.3)
|
37
|
+
guard (0.3.4)
|
38
|
+
thor (~> 0.14.6)
|
39
|
+
guard-rspec (0.3.1)
|
40
|
+
guard (>= 0.2.2)
|
35
41
|
hashie (1.0.0)
|
36
42
|
httparty (0.7.4)
|
37
43
|
crack (= 0.1.8)
|
38
44
|
i18n (0.5.0)
|
39
|
-
infinity_test (1.0.2)
|
40
|
-
notifiers (>= 1.1.0)
|
41
|
-
watchr (>= 0.7)
|
42
45
|
json (1.5.1)
|
46
|
+
libnotify (0.5.5)
|
43
47
|
mail (2.2.15)
|
44
48
|
activesupport (>= 2.3.6)
|
45
49
|
i18n (>= 0.4.0)
|
@@ -58,10 +62,12 @@ GEM
|
|
58
62
|
net-ssh (>= 2.0.9)
|
59
63
|
net-ssh (2.1.3)
|
60
64
|
nokogiri (1.4.4)
|
61
|
-
notifiers (1.1.0)
|
62
65
|
oauth (0.4.4)
|
63
66
|
polyglot (0.3.1)
|
64
67
|
rack (1.2.2)
|
68
|
+
rb-fsevent (0.4.0)
|
69
|
+
rb-inotify (0.8.5)
|
70
|
+
ffi (>= 0.5.0)
|
65
71
|
rspec (2.5.0)
|
66
72
|
rspec-core (~> 2.5.0)
|
67
73
|
rspec-expectations (~> 2.5.0)
|
@@ -69,11 +75,12 @@ GEM
|
|
69
75
|
rspec-core (2.5.1)
|
70
76
|
rspec-expectations (2.5.0)
|
71
77
|
diff-lcs (~> 1.1.2)
|
72
|
-
rspec-instafail (0.1.
|
78
|
+
rspec-instafail (0.1.7)
|
73
79
|
rspec-mocks (2.5.0)
|
74
80
|
ruby-hmac (0.4.0)
|
75
|
-
ruby-progressbar (0.0.
|
81
|
+
ruby-progressbar (0.0.10)
|
76
82
|
simple_oauth (0.1.4)
|
83
|
+
thor (0.14.6)
|
77
84
|
timecop (0.3.5)
|
78
85
|
treetop (1.4.9)
|
79
86
|
polyglot (>= 0.3.1)
|
@@ -84,7 +91,6 @@ GEM
|
|
84
91
|
multi_json (~> 0.0.5)
|
85
92
|
multi_xml (~> 0.2.0)
|
86
93
|
simple_oauth (~> 0.1.3)
|
87
|
-
watchr (0.7)
|
88
94
|
|
89
95
|
PLATFORMS
|
90
96
|
ruby
|
@@ -93,14 +99,19 @@ DEPENDENCIES
|
|
93
99
|
dropbox (~> 1.2.3)
|
94
100
|
fog (~> 0.7.0)
|
95
101
|
fuubar
|
102
|
+
growl
|
103
|
+
guard
|
104
|
+
guard-rspec
|
96
105
|
httparty (~> 0.7.4)
|
97
|
-
infinity_test
|
98
106
|
json (~> 1.5.1)
|
107
|
+
libnotify
|
99
108
|
mail (~> 2.2.15)
|
100
109
|
mocha
|
101
110
|
net-scp (~> 1.0.4)
|
102
111
|
net-sftp (~> 2.0.5)
|
103
112
|
net-ssh (~> 2.1.3)
|
113
|
+
rb-fsevent
|
114
|
+
rb-inotify
|
104
115
|
rspec
|
105
116
|
timecop
|
106
117
|
twitter (~> 1.1.2)
|
data/Guardfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
##
|
2
|
+
# To run the test suite against all 3 rubies: 1.9.2, 1.8.7 and REE, simply run the following command:
|
3
|
+
# $ guard start
|
4
|
+
#
|
5
|
+
# Be use you are using RVM and have Ruby 1.9.2, 1.8.7 and REE installed as well as all
|
6
|
+
# Backup's gem dependencies for each of these Ruby intepreters.
|
7
|
+
|
8
|
+
guard 'rspec',
|
9
|
+
:version => 2,
|
10
|
+
:rvm => ['1.9.2', '1.8.7', 'ree'],
|
11
|
+
:bundler => true,
|
12
|
+
:cli => '--color --format Fuubar --fail-fast' do
|
13
|
+
|
14
|
+
watch(%r{^spec/.+_spec\.rb})
|
15
|
+
watch(%r{^lib/(.+)\.rb}) { 'spec' }
|
16
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
17
|
+
end
|
data/README.md
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
Backup 3
|
2
2
|
========
|
3
3
|
|
4
|
-
Backup is a RubyGem
|
4
|
+
Backup is a RubyGem, written for Linux and Mac OSX, that allows you to easily perform backup operations on both your remote, as well as your local environment. It provides you with an elegant DSL in Ruby for modeling (configuring) your backups. Backup has built-in support for various databases, storage protocols/services, syncers, compressors, encryptors and notifiers which you can mix and match. It was built with modularity, extensibility and simplicity in mind.
|
5
|
+
|
5
6
|
|
6
7
|
Author
|
7
8
|
------
|
8
9
|
|
9
|
-
**Michael van Rooijen ( [@meskyanichi](http://twitter.com/#!/meskyanichi) )**
|
10
|
+
**[Michael van Rooijen](http://michaelvanrooijen.com/) ( [@meskyanichi](http://twitter.com/#!/meskyanichi) )**
|
10
11
|
|
11
12
|
Drop me a message for any questions, suggestions, requests, bugs or submit them to the [issue log](https://github.com/meskyanichi/backup/issues).
|
12
13
|
|
14
|
+
|
13
15
|
Installation
|
14
16
|
------------
|
15
17
|
|
@@ -27,7 +29,7 @@ I recommend you read this README first, and refer to the [Wiki pages](https://gi
|
|
27
29
|
What Backup 3 currently supports
|
28
30
|
================================
|
29
31
|
|
30
|
-
|
32
|
+
Below you find a list of components that Backup currently supports. Each of these compontents is isolated, meaning that adding new databases, storage location / service, compressor, encryptor or notifier is easy to do.
|
31
33
|
|
32
34
|
Database Support
|
33
35
|
----------------
|
@@ -47,8 +49,8 @@ Filesystem Support
|
|
47
49
|
|
48
50
|
[Archive Wiki Page](https://github.com/meskyanichi/backup/wiki/Archives)
|
49
51
|
|
50
|
-
Storage Locations
|
51
|
-
|
52
|
+
Storage Locations and Services
|
53
|
+
------------------------------
|
52
54
|
|
53
55
|
- Amazon Simple Storage Service (S3)
|
54
56
|
- Rackspace Cloud Files (Mosso)
|
@@ -82,6 +84,7 @@ Compressors
|
|
82
84
|
-----------
|
83
85
|
|
84
86
|
- Gzip
|
87
|
+
- Bzip2
|
85
88
|
|
86
89
|
[Compressors Wiki Page](https://github.com/meskyanichi/backup/wiki/Compressors)
|
87
90
|
|
@@ -99,6 +102,7 @@ Notifiers
|
|
99
102
|
- Mail
|
100
103
|
- Twitter
|
101
104
|
- Campfire
|
105
|
+
- Presently
|
102
106
|
|
103
107
|
[Notifiers Wiki Page](https://github.com/meskyanichi/backup/wiki/Notifiers)
|
104
108
|
|
@@ -109,21 +113,11 @@ Supported Ruby versions (Tested with RSpec)
|
|
109
113
|
- Ruby 1.8.7
|
110
114
|
- Ruby Enterprise Edition 1.8.7
|
111
115
|
|
112
|
-
Environments
|
113
|
-
------------
|
114
|
-
|
115
|
-
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.
|
116
|
-
|
117
|
-
Compatibility
|
118
|
-
-------------
|
119
116
|
|
120
|
-
|
117
|
+
A sample Backup configuration file
|
118
|
+
==================================
|
121
119
|
|
122
|
-
|
123
|
-
A sample "Backup" configuration file
|
124
|
-
====================================
|
125
|
-
|
126
|
-
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)**
|
120
|
+
This is a Backup configuration file. Check it out and read the explanation below. Backup has a [great wiki](https://github.com/meskyanichi/backup/wiki) which explains each component of Backup in detail.
|
127
121
|
|
128
122
|
Backup::Model.new(:sample_backup, 'A sample backup configuration') do
|
129
123
|
|
@@ -191,45 +185,33 @@ Below you see a sample configuration file you could create for Backup 3. Just re
|
|
191
185
|
|
192
186
|
end
|
193
187
|
|
194
|
-
###
|
195
|
-
|
196
|
-
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 compress the backup file using Gzip (with the mode set to "best", rather than "fast" for best compression). 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). Then it'll store the backup file to Amazon S3 in to 'my_bucket/backups'. Next, we're going to use the S3 Syncer to create a mirror of the `/var/apps/my_app/public/videos` and `/var/apps/my_app/public/music` directories on Amazon S3. (This will not package, compress, encrypt - but will directly sync the specified directories "as is" to your S3 bucket). Finally, it'll notify me by email if the backup raises an error/exception during the process, indicating that something went wrong. However, it does not notify me by email when successful backups occur because I set `mail.on_success` to `false`. It'll also notify me by Twitter when failed backups occur, but also when successful ones occur because I set the `tweet.on_success` to `true`.
|
197
|
-
|
198
|
-
### Things to note
|
199
|
-
|
200
|
-
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.
|
188
|
+
### Brief explanation for the above example configuration
|
201
189
|
|
202
|
-
|
190
|
+
It will dump two databases (MySQL and MongoDB), it'll create two (.t)archives (user_avatars and logs). It'll package the two database and two archives together in a single (.t)archive. It'll run the Gzip compressor to compress that archive, and then it'll run the OpenSSL encryptor to encrypt the compressed archive. Then that encrypted archive will be stored to your Amazon S3 account. If all goes well, and no exceptions are raised, you'll be notified via the Twitter notifier that the backup succeeded. If there was an exception raised during the backup process, then you'd receive an email in your inbox containing detailed exception information, as well as receive a simple Twitter message that something went wrong.
|
203
191
|
|
204
|
-
|
192
|
+
As you can see, you can freely mix and match **archives**, **databases**, **compressors**, **encryptors**, **storages** and **notifiers** for your backups. You could even specify 3 storage locations: Amazon S3, Rackspace Cloud Files and Dropbox, it'd then store your packaged backup to 3 separate locations for high redundancy. This also applies to encryptors, you could double encrypt your backup with OpenSSL followed by GPG if you wanted.
|
205
193
|
|
206
|
-
|
194
|
+
Additionally we have also defined a **S3 Syncer** ( `sync_with S3` ), which does not follow the above process of archiving/compression/encryption, but instead will directly sync the whole `videos` and `music` folder structures from your machine to your Amazon S3 account. (very efficient and cost-effective since it will only transfer files that were changed!)
|
207
195
|
|
208
|
-
|
209
|
-
|
210
|
-
Check out the Wiki for more information on all the above subjects.
|
211
|
-
|
212
|
-
### And that's it!
|
213
|
-
|
214
|
-
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, syncers, 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).
|
196
|
+
There are more **archives**, **databases**, **compressors**, **encryptors**, **storages** and **notifiers** than displayed in the example, all available components are listed at the top of this README, as well as in the [Wiki](https://github.com/meskyanichi/backup/wiki).
|
215
197
|
|
216
198
|
### Running the example
|
217
199
|
|
218
|
-
|
219
|
-
The `:sample_backup` is called the "id", or "trigger". This is used to identify the backup procedure/file and initialize it.
|
200
|
+
Notice the `Backup::Model.new(:sample_backup, 'A sample backup configuration') do` at the top of the above example. The `:sample_backup` is called the **trigger**. This is used to identify the backup procedure/file and initialize it.
|
220
201
|
|
221
|
-
backup perform -t sample_backup
|
202
|
+
backup perform -t [--trigger] sample_backup
|
222
203
|
|
223
|
-
|
204
|
+
Now it'll run the backup, it's as simple as that.
|
224
205
|
|
225
206
|
### Automatic backups
|
226
207
|
|
227
|
-
Since
|
208
|
+
Since Backup is a simple command line utility, you should write a crontask to invoke it periodically. I recommend you use [Whenever](https://github.com/javan/whenever) to manage your crontab. It'll allow you to write to the crontab in pure Ruby, it provides an elegant DSL to do so, for example:
|
228
209
|
|
229
210
|
every 6.hours do
|
230
|
-
command "backup perform
|
211
|
+
command "backup perform --trigger sample_backup"
|
231
212
|
end
|
232
213
|
|
214
|
+
With this in place, run `whenever --update-crontab backup` to write this Ruby syntax to the crontab in cron-syntax. The operating system will now invoke `backup perform --trigger sample_backup` every 6 hours. Check out the Whenever project page for more information.
|
233
215
|
|
234
216
|
Documentation
|
235
217
|
-------------
|
@@ -266,8 +248,41 @@ Contributors
|
|
266
248
|
<td><a href="https://github.com/szimmermann" target="_blank">Stefan Zimmermann ( szimmermann )</a></td>
|
267
249
|
<td>Enabling package/archive (tar utility) support for more Linux distro's (FreeBSD, etc)</td>
|
268
250
|
</tr>
|
251
|
+
<tr>
|
252
|
+
<td><a href="https://github.com/trystant" target="_blank">Mark Nyon ( trystant )</a></td>
|
253
|
+
<td>Helping discuss MongoDump Lock/FSync problem</td>
|
254
|
+
</tr>
|
255
|
+
<tr>
|
256
|
+
<td><a href="https://github.com/imanel" target="_blank">Bernard Potocki ( imanel )</a></td>
|
257
|
+
<td>Helping discuss MongoDump Lock/FSync problem + Submitting a patch</td>
|
258
|
+
</tr>
|
259
|
+
<tr>
|
260
|
+
<td><a href="https://github.com/tomash" target="_blank">Tomasz Stachewicz ( tomash )</a></td>
|
261
|
+
<td>Helping discuss MongoDump Lock/FSync problem + Submitting a patch</td>
|
262
|
+
</tr>
|
263
|
+
<tr>
|
264
|
+
<td><a href="https://github.com/lapluviosilla" target="_blank">Paul Strong ( lapluviosilla )</a></td>
|
265
|
+
<td>Helping discuss MongoDump Lock/FSync problem</td>
|
266
|
+
</tr>
|
267
|
+
<tr>
|
268
|
+
<td><a href="https://github.com/rgnitz" target="_blank">Ryan ( rgnitz )</a></td>
|
269
|
+
<td>Helping discuss MongoDump Lock/FSync problem</td>
|
270
|
+
</tr>
|
271
|
+
<tr>
|
272
|
+
<td><a href="https://github.com/tsigo" target="_blank">Robert Speicher ( tsigo )</a></td>
|
273
|
+
<td>Adding the --quiet [-q] feature to Backup to silence console logging</td>
|
274
|
+
</tr>
|
275
|
+
<tr>
|
276
|
+
<td><a href="https://github.com/jwhitcraft" target="_blank">Jon Whitcraft ( jwhitcraft )</a></td>
|
277
|
+
<td>Adding the ability to add additional options to the S3Syncer</td>
|
278
|
+
</tr>
|
279
|
+
<tr>
|
280
|
+
<td><a href="https://github.com/bgarret" target="_blank">Benoit Garret ( bgarret )</a></td>
|
281
|
+
<td>Presently notifier</td>
|
282
|
+
</tr>
|
269
283
|
</table>
|
270
284
|
|
285
|
+
|
271
286
|
Want to contribute?
|
272
287
|
-------------------
|
273
288
|
|
@@ -280,8 +295,38 @@ Want to contribute?
|
|
280
295
|
|
281
296
|
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.
|
282
297
|
|
298
|
+
Easily run tests against all three Ruby versions
|
299
|
+
------------------------------------------------
|
300
|
+
|
301
|
+
Install [RVM](https://rvm.beginrescueend.com/) and use it to install Ruby 1.9.2, 1.8.7 and REE.
|
302
|
+
|
303
|
+
rvm install 1.9.2 && rvm install 1.8.7 && rvm install ree
|
304
|
+
|
305
|
+
Once these are installed, go ahead and install all the necessary dependencies.
|
306
|
+
|
307
|
+
cd backup
|
308
|
+
rvm use 1.9.2 && gem install bundler && bundle install
|
309
|
+
rvm use 1.8.7 && gem install bundler && bundle install
|
310
|
+
rvm use ree && gem install bundler && bundle install
|
311
|
+
|
312
|
+
The Backup gem uses [Guard](https://github.com/guard/guard) along with [Guard::RSpec](https://github.com/guard/guard-rspec) to quickly and easily test Backup's code against all three Rubies. If you've done the above, all you have to do is run:
|
313
|
+
|
314
|
+
guard start
|
315
|
+
|
316
|
+
from Backup's root and that's it. It'll now test against all three Rubies each time you adjust a file in the `lib` or `spec` directories.
|
317
|
+
|
318
|
+
|
319
|
+
Or contribute by writing blogs/tutorials
|
320
|
+
----------------------------------------
|
321
|
+
|
322
|
+
- http://erik.debill.org/2011/03/26/csing-backup-with-rails
|
323
|
+
- http://blog.noizeramp.com/2011/03/31/backing-up-backup-ruby-gem/
|
324
|
+
- http://www.sebaugereau.com/using-ruby-to-backup-with-beauty
|
325
|
+
- http://outofti.me/post/4159686269/backup-with-pgbackups
|
326
|
+
- http://h2ik.co/2011/03/backing-up-with-ruby/
|
327
|
+
|
283
328
|
|
284
329
|
Backup 2 - Issues, Wiki, Source, Gems
|
285
330
|
=====================================
|
286
331
|
|
287
|
-
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).
|
332
|
+
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).
|
data/backup.gemspec
CHANGED
@@ -12,15 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.authors = 'Michael van Rooijen'
|
13
13
|
gem.email = 'meskyanichi@gmail.com'
|
14
14
|
gem.homepage = 'http://rubygems.org/gems/backup'
|
15
|
-
gem.summary = 'Backup is a RubyGem
|
16
|
-
that allows you to configure and perform backups in a simple manner using
|
17
|
-
an elegant Ruby DSL. It supports various databases (MySQL, PostgreSQL, MongoDB and Redis),
|
18
|
-
it supports various storage locations (Amazon S3, Rackspace Cloud Files, Dropbox, any remote
|
19
|
-
server through FTP, SFTP, SCP and RSync), it provide Syncers (RSync, S3) for efficient backups,
|
20
|
-
it can archive files and directories, it can cycle backups, it can do incremental backups, it
|
21
|
-
can compress backups, it can encrypt backups (OpenSSL or GPG), it can notify you about
|
22
|
-
successful and/or failed backups (Email, Twitter and Campfire). It is very extensible and easy to add new
|
23
|
-
functionality to. It\'s easy to use.'
|
15
|
+
gem.summary = 'Backup is a RubyGem, written for Linux and Mac OSX, that allows you to easily perform backup operations on both your remote, as well as your local environment. It provides you with an elegant DSL in Ruby for modeling (configuring) your backups. Backup has built-in support for various databases, storage protocols/services, syncers, compressors, encryptors and notifiers which you can mix and match. It was built with modularity, extensibility and simplicity in mind.'
|
24
16
|
|
25
17
|
##
|
26
18
|
# Files and folder that need to be compiled in to the Ruby Gem
|
data/lib/backup.rb
CHANGED
@@ -18,10 +18,10 @@ module Backup
|
|
18
18
|
# database MySQL do |mysql|
|
19
19
|
DATABASES = ['MySQL', 'PostgreSQL', 'MongoDB', 'Redis']
|
20
20
|
STORAGES = ['S3', 'CloudFiles', 'Dropbox', 'FTP', 'SFTP', 'SCP', 'RSync']
|
21
|
-
COMPRESSORS = ['Gzip']
|
21
|
+
COMPRESSORS = ['Gzip', 'Bzip2']
|
22
22
|
ENCRYPTORS = ['OpenSSL', 'GPG']
|
23
23
|
SYNCERS = ['RSync', 'S3']
|
24
|
-
NOTIFIERS = ['Mail', 'Twitter', 'Campfire']
|
24
|
+
NOTIFIERS = ['Mail', 'Twitter', 'Campfire', 'Presently']
|
25
25
|
|
26
26
|
##
|
27
27
|
# Backup's internal paths
|
@@ -64,6 +64,7 @@ module Backup
|
|
64
64
|
autoload :Mail, File.join(CONFIGURATION_PATH, 'notifier', 'mail')
|
65
65
|
autoload :Twitter, File.join(CONFIGURATION_PATH, 'notifier', 'twitter')
|
66
66
|
autoload :Campfire, File.join(CONFIGURATION_PATH, 'notifier', 'campfire')
|
67
|
+
autoload :Presently, File.join(CONFIGURATION_PATH, 'notifier', 'presently')
|
67
68
|
end
|
68
69
|
|
69
70
|
module Encryptor
|
@@ -75,6 +76,7 @@ module Backup
|
|
75
76
|
module Compressor
|
76
77
|
autoload :Base, File.join(CONFIGURATION_PATH, 'compressor', 'base')
|
77
78
|
autoload :Gzip, File.join(CONFIGURATION_PATH, 'compressor', 'gzip')
|
79
|
+
autoload :Bzip2, File.join(CONFIGURATION_PATH, 'compressor', 'bzip2')
|
78
80
|
end
|
79
81
|
|
80
82
|
module Storage
|
@@ -139,6 +141,7 @@ module Backup
|
|
139
141
|
module Compressor
|
140
142
|
autoload :Base, File.join(COMPRESSOR_PATH, 'base')
|
141
143
|
autoload :Gzip, File.join(COMPRESSOR_PATH, 'gzip')
|
144
|
+
autoload :Bzip2, File.join(COMPRESSOR_PATH, 'bzip2')
|
142
145
|
end
|
143
146
|
|
144
147
|
##
|
@@ -157,6 +160,7 @@ module Backup
|
|
157
160
|
autoload :Mail, File.join(NOTIFIER_PATH, 'mail')
|
158
161
|
autoload :Twitter, File.join(NOTIFIER_PATH, 'twitter')
|
159
162
|
autoload :Campfire, File.join(NOTIFIER_PATH, 'campfire')
|
163
|
+
autoload :Presently, File.join(NOTIFIER_PATH, 'presently')
|
160
164
|
end
|
161
165
|
|
162
166
|
##
|
data/lib/backup/archive.rb
CHANGED
@@ -66,7 +66,7 @@ module Backup
|
|
66
66
|
# Returns a "tar-ready" string of all the specified excludes combined
|
67
67
|
def paths_to_exclude
|
68
68
|
if excludes.any?
|
69
|
-
|
69
|
+
excludes.map{ |e| "--exclude='#{e}'" }.join(" ")
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
data/lib/backup/cli.rb
CHANGED
@@ -22,10 +22,10 @@ module Backup
|
|
22
22
|
# and pass that in to the Backup::CLI#raise_if_command_not_found
|
23
23
|
def run(command)
|
24
24
|
command.gsub!(/^\s+/, '')
|
25
|
-
%x[#{command}]
|
26
25
|
raise_if_command_not_found!(
|
27
26
|
command.slice(0, command.index(/\s/)).split('/')[-1]
|
28
27
|
)
|
28
|
+
%x[#{command}]
|
29
29
|
end
|
30
30
|
|
31
31
|
##
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Backup
|
4
|
+
module Compressor
|
5
|
+
class Bzip2 < Base
|
6
|
+
|
7
|
+
##
|
8
|
+
# Tells Backup::Compressor::Bzip2 to compress
|
9
|
+
# better (-9) rather than faster when set to true
|
10
|
+
attr_writer :best
|
11
|
+
|
12
|
+
##
|
13
|
+
# Tells Backup::Compressor::Bzip2 to compress
|
14
|
+
# faster (-1) rather than better when set to true
|
15
|
+
attr_writer :fast
|
16
|
+
|
17
|
+
##
|
18
|
+
# Creates a new instance of Backup::Compressor::Bzip2 and
|
19
|
+
# configures it to either compress faster or better
|
20
|
+
# bzip2 compresses by default with -9 (best compression)
|
21
|
+
# and lower block sizes don't make things significantly faster
|
22
|
+
# (according to official bzip2 docs)
|
23
|
+
def initialize(&block)
|
24
|
+
load_defaults!
|
25
|
+
|
26
|
+
@best ||= false
|
27
|
+
@fast ||= false
|
28
|
+
|
29
|
+
instance_eval(&block) if block_given?
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# Performs the compression of the packages backup file
|
34
|
+
def perform!
|
35
|
+
log!
|
36
|
+
run("#{ utility(:bzip2) } #{ options } '#{ Backup::Model.file }'")
|
37
|
+
Backup::Model.extension += '.bz2'
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
##
|
43
|
+
# Combines the provided options and returns a bzip2 options string
|
44
|
+
def options
|
45
|
+
(best + fast).join("\s")
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Returns the bzip2 option syntax for compressing
|
50
|
+
# setting @best to true is redundant, as bzip2 compresses best by default
|
51
|
+
def best
|
52
|
+
return ['--best'] if @best; []
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Returns the bzip2 option syntax for compressing
|
57
|
+
# (not significantly) faster when @fast is set to true
|
58
|
+
def fast
|
59
|
+
return ['--fast'] if @fast; []
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|