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.
- data/.gitignore +2 -0
- data/.infinity_test +7 -0
- data/.rspec +3 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +88 -0
- data/LICENSE.md +24 -0
- data/README.md +189 -75
- data/backup.gemspec +41 -0
- data/bin/backup +161 -90
- data/lib/backup.rb +133 -117
- data/lib/backup/archive.rb +54 -0
- data/lib/backup/cli.rb +50 -0
- data/lib/backup/compressor/base.rb +17 -0
- data/lib/backup/compressor/gzip.rb +61 -0
- data/lib/backup/configuration/base.rb +7 -67
- data/lib/backup/configuration/compressor/base.rb +10 -0
- data/lib/backup/configuration/compressor/gzip.rb +23 -0
- data/lib/backup/configuration/database/base.rb +18 -0
- data/lib/backup/configuration/database/mongodb.rb +37 -0
- data/lib/backup/configuration/database/mysql.rb +37 -0
- data/lib/backup/configuration/database/postgresql.rb +37 -0
- data/lib/backup/configuration/database/redis.rb +35 -0
- data/lib/backup/configuration/encryptor/base.rb +10 -0
- data/lib/backup/configuration/encryptor/gpg.rb +17 -0
- data/lib/backup/configuration/encryptor/open_ssl.rb +26 -0
- data/lib/backup/configuration/helpers.rb +47 -17
- data/lib/backup/configuration/notifier/base.rb +39 -0
- data/lib/backup/configuration/notifier/mail.rb +52 -0
- data/lib/backup/configuration/storage/base.rb +18 -0
- data/lib/backup/configuration/storage/cloudfiles.rb +21 -0
- data/lib/backup/configuration/storage/dropbox.rb +25 -0
- data/lib/backup/configuration/storage/ftp.rb +25 -0
- data/lib/backup/configuration/storage/rsync.rb +25 -0
- data/lib/backup/configuration/storage/s3.rb +25 -0
- data/lib/backup/configuration/storage/scp.rb +25 -0
- data/lib/backup/configuration/storage/sftp.rb +25 -0
- data/lib/backup/database/base.rb +33 -0
- data/lib/backup/database/mongodb.rb +137 -0
- data/lib/backup/database/mysql.rb +104 -0
- data/lib/backup/database/postgresql.rb +111 -0
- data/lib/backup/database/redis.rb +105 -0
- data/lib/backup/encryptor/base.rb +17 -0
- data/lib/backup/encryptor/gpg.rb +78 -0
- data/lib/backup/encryptor/open_ssl.rb +67 -0
- data/lib/backup/finder.rb +39 -0
- data/lib/backup/logger.rb +80 -0
- data/lib/backup/model.rb +249 -0
- data/lib/backup/notifier/base.rb +29 -0
- data/lib/backup/notifier/binder.rb +32 -0
- data/lib/backup/notifier/mail.rb +141 -0
- data/lib/backup/notifier/templates/notify_failure.erb +31 -0
- data/lib/backup/notifier/templates/notify_success.erb +16 -0
- data/lib/backup/storage/base.rb +60 -3
- data/lib/backup/storage/cloudfiles.rb +85 -6
- data/lib/backup/storage/dropbox.rb +74 -4
- data/lib/backup/storage/ftp.rb +103 -27
- data/lib/backup/storage/object.rb +45 -0
- data/lib/backup/storage/rsync.rb +100 -0
- data/lib/backup/storage/s3.rb +100 -7
- data/lib/backup/storage/scp.rb +94 -19
- data/lib/backup/storage/sftp.rb +94 -19
- data/lib/backup/version.rb +70 -1
- data/lib/templates/archive +4 -0
- data/lib/templates/compressor/gzip +4 -0
- data/lib/templates/database/mongodb +10 -0
- data/lib/templates/database/mysql +11 -0
- data/lib/templates/database/postgresql +11 -0
- data/lib/templates/database/redis +10 -0
- data/lib/templates/encryptor/gpg +9 -0
- data/lib/templates/encryptor/openssl +5 -0
- data/lib/templates/notifier/mail +14 -0
- data/lib/templates/readme +15 -0
- data/lib/templates/storage/cloudfiles +7 -0
- data/lib/templates/storage/dropbox +8 -0
- data/lib/templates/storage/ftp +8 -0
- data/lib/templates/storage/rsync +7 -0
- data/lib/templates/storage/s3 +8 -0
- data/lib/templates/storage/scp +8 -0
- data/lib/templates/storage/sftp +8 -0
- data/spec/archive_spec.rb +53 -0
- data/spec/backup_spec.rb +11 -0
- data/spec/compressor/gzip_spec.rb +59 -0
- data/spec/configuration/base_spec.rb +35 -0
- data/spec/configuration/compressor/gzip_spec.rb +28 -0
- data/spec/configuration/database/base_spec.rb +16 -0
- data/spec/configuration/database/mongodb_spec.rb +30 -0
- data/spec/configuration/database/mysql_spec.rb +32 -0
- data/spec/configuration/database/postgresql_spec.rb +32 -0
- data/spec/configuration/database/redis_spec.rb +30 -0
- data/spec/configuration/encryptor/gpg_spec.rb +25 -0
- data/spec/configuration/encryptor/open_ssl_spec.rb +31 -0
- data/spec/configuration/notifier/mail_spec.rb +32 -0
- data/spec/configuration/storage/cloudfiles_spec.rb +34 -0
- data/spec/configuration/storage/dropbox_spec.rb +40 -0
- data/spec/configuration/storage/ftp_spec.rb +40 -0
- data/spec/configuration/storage/rsync_spec.rb +37 -0
- data/spec/configuration/storage/s3_spec.rb +37 -0
- data/spec/configuration/storage/scp_spec.rb +40 -0
- data/spec/configuration/storage/sftp_spec.rb +40 -0
- data/spec/database/base_spec.rb +30 -0
- data/spec/database/mongodb_spec.rb +144 -0
- data/spec/database/mysql_spec.rb +150 -0
- data/spec/database/postgresql_spec.rb +164 -0
- data/spec/database/redis_spec.rb +122 -0
- data/spec/encryptor/gpg_spec.rb +57 -0
- data/spec/encryptor/open_ssl_spec.rb +102 -0
- data/spec/logger_spec.rb +37 -0
- data/spec/model_spec.rb +236 -0
- data/spec/notifier/mail_spec.rb +97 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/storage/base_spec.rb +33 -0
- data/spec/storage/cloudfiles_spec.rb +102 -0
- data/spec/storage/dropbox_spec.rb +89 -0
- data/spec/storage/ftp_spec.rb +133 -0
- data/spec/storage/object_spec.rb +74 -0
- data/spec/storage/rsync_spec.rb +115 -0
- data/spec/storage/s3_spec.rb +110 -0
- data/spec/storage/scp_spec.rb +129 -0
- data/spec/storage/sftp_spec.rb +125 -0
- data/spec/version_spec.rb +32 -0
- metadata +139 -123
- data/CHANGELOG +0 -131
- data/LICENSE +0 -20
- data/generators/backup/backup_generator.rb +0 -69
- data/generators/backup/templates/backup.rake +0 -56
- data/generators/backup/templates/backup.rb +0 -253
- data/generators/backup/templates/create_backup_tables.rb +0 -18
- data/generators/backup_update/backup_update_generator.rb +0 -50
- data/generators/backup_update/templates/migrations/update_backup_tables.rb +0 -27
- data/lib/backup/adapters/archive.rb +0 -34
- data/lib/backup/adapters/base.rb +0 -167
- data/lib/backup/adapters/custom.rb +0 -41
- data/lib/backup/adapters/mongo_db.rb +0 -139
- data/lib/backup/adapters/mysql.rb +0 -60
- data/lib/backup/adapters/postgresql.rb +0 -60
- data/lib/backup/adapters/sqlite.rb +0 -25
- data/lib/backup/command_helper.rb +0 -14
- data/lib/backup/configuration/adapter.rb +0 -21
- data/lib/backup/configuration/adapter_options.rb +0 -8
- data/lib/backup/configuration/attributes.rb +0 -19
- data/lib/backup/configuration/mail.rb +0 -20
- data/lib/backup/configuration/smtp.rb +0 -8
- data/lib/backup/configuration/storage.rb +0 -8
- data/lib/backup/connection/cloudfiles.rb +0 -75
- data/lib/backup/connection/dropbox.rb +0 -63
- data/lib/backup/connection/s3.rb +0 -88
- data/lib/backup/core_ext/object.rb +0 -5
- data/lib/backup/environment/base.rb +0 -12
- data/lib/backup/environment/rails_configuration.rb +0 -15
- data/lib/backup/environment/unix_configuration.rb +0 -109
- data/lib/backup/mail/base.rb +0 -97
- data/lib/backup/mail/mail.txt +0 -7
- data/lib/backup/record/base.rb +0 -65
- data/lib/backup/record/cloudfiles.rb +0 -28
- data/lib/backup/record/dropbox.rb +0 -27
- data/lib/backup/record/ftp.rb +0 -39
- data/lib/backup/record/local.rb +0 -26
- data/lib/backup/record/s3.rb +0 -25
- data/lib/backup/record/scp.rb +0 -33
- data/lib/backup/record/sftp.rb +0 -38
- data/lib/backup/storage/local.rb +0 -22
- data/lib/generators/backup/USAGE +0 -10
- data/lib/generators/backup/backup_generator.rb +0 -47
- data/lib/generators/backup/templates/backup.rake +0 -56
- data/lib/generators/backup/templates/backup.rb +0 -236
- data/lib/generators/backup/templates/create_backup_tables.rb +0 -18
- data/setup/backup.rb +0 -257
- data/setup/backup.sqlite3 +0 -0
data/.gitignore
ADDED
data/.infinity_test
ADDED
data/.rspec
ADDED
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
|
data/Gemfile.lock
ADDED
@@ -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
|
data/LICENSE.md
ADDED
@@ -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
|
-
|
1
|
+
Backup 3
|
2
|
+
========
|
2
3
|
|
3
|
-
|
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
|
-
|
6
|
+
Author
|
7
|
+
------
|
6
8
|
|
7
|
-
|
9
|
+
Michael van Rooijen ( [@meskyanichi](http://twitter.com/#!/meskyanichi) )
|
8
10
|
|
9
|
-
|
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
|
-
|
13
|
+
Installation
|
14
|
+
------------
|
14
15
|
|
15
|
-
|
16
|
-
* [Fernandoluizao - Fernando Migliorini Luizão](http://github.com/fernandoluizao)
|
16
|
+
To get the latest stable version
|
17
17
|
|
18
|
-
|
18
|
+
gem install backup
|
19
19
|
|
20
|
-
*
|
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
|
-
|
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
|
-
|
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
|
-
|
29
|
+
What Backup 3 currently supports
|
30
|
+
================================
|
40
31
|
|
41
|
-
|
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
|
-
|
34
|
+
Database Support
|
35
|
+
----------------
|
49
36
|
|
50
|
-
|
37
|
+
- MySQL
|
38
|
+
- PostgreSQL
|
39
|
+
- MongoDB
|
40
|
+
- Redis
|
51
41
|
|
52
|
-
|
42
|
+
[Database Wiki Page](https://github.com/meskyanichi/backup/wiki/Databases)
|
53
43
|
|
54
|
-
|
55
|
-
|
44
|
+
Filesystem Support
|
45
|
+
------------------
|
56
46
|
|
57
|
-
|
47
|
+
- Files
|
48
|
+
- Folders
|
58
49
|
|
59
|
-
|
50
|
+
[Archive Wiki Page](https://github.com/meskyanichi/backup/wiki/Archives)
|
60
51
|
|
61
|
-
|
52
|
+
Storage Locations
|
53
|
+
-----------------
|
62
54
|
|
63
|
-
|
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
|
-
|
60
|
+
[Storage Wiki Page](https://github.com/meskyanichi/backup/wiki/Storages)
|
66
61
|
|
67
|
-
|
62
|
+
Storage Features
|
63
|
+
----------------
|
68
64
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
-
|
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
|
-
|
186
|
+
### And that's it!
|
93
187
|
|
94
|
-
|
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
|
-
|
190
|
+
### Running the example
|
97
191
|
|
98
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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).
|