backup-agoddard 3.0.27
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of backup-agoddard might be problematic. Click here for more details.
- data/.gitignore +8 -0
- data/.travis.yml +10 -0
- data/Gemfile +28 -0
- data/Guardfile +23 -0
- data/LICENSE.md +24 -0
- data/README.md +478 -0
- data/backup.gemspec +32 -0
- data/bin/backup +11 -0
- data/lib/backup.rb +133 -0
- data/lib/backup/archive.rb +117 -0
- data/lib/backup/binder.rb +22 -0
- data/lib/backup/cleaner.rb +121 -0
- data/lib/backup/cli/helpers.rb +93 -0
- data/lib/backup/cli/utility.rb +255 -0
- data/lib/backup/compressor/base.rb +35 -0
- data/lib/backup/compressor/bzip2.rb +50 -0
- data/lib/backup/compressor/custom.rb +53 -0
- data/lib/backup/compressor/gzip.rb +50 -0
- data/lib/backup/compressor/lzma.rb +52 -0
- data/lib/backup/compressor/pbzip2.rb +59 -0
- data/lib/backup/config.rb +174 -0
- data/lib/backup/configuration.rb +33 -0
- data/lib/backup/configuration/helpers.rb +130 -0
- data/lib/backup/configuration/store.rb +24 -0
- data/lib/backup/database/base.rb +53 -0
- data/lib/backup/database/mongodb.rb +230 -0
- data/lib/backup/database/mysql.rb +160 -0
- data/lib/backup/database/postgresql.rb +144 -0
- data/lib/backup/database/redis.rb +136 -0
- data/lib/backup/database/riak.rb +67 -0
- data/lib/backup/dependency.rb +108 -0
- data/lib/backup/encryptor/base.rb +29 -0
- data/lib/backup/encryptor/gpg.rb +760 -0
- data/lib/backup/encryptor/open_ssl.rb +72 -0
- data/lib/backup/errors.rb +124 -0
- data/lib/backup/hooks.rb +68 -0
- data/lib/backup/logger.rb +152 -0
- data/lib/backup/model.rb +409 -0
- data/lib/backup/notifier/base.rb +81 -0
- data/lib/backup/notifier/campfire.rb +155 -0
- data/lib/backup/notifier/hipchat.rb +93 -0
- data/lib/backup/notifier/mail.rb +206 -0
- data/lib/backup/notifier/prowl.rb +65 -0
- data/lib/backup/notifier/pushover.rb +88 -0
- data/lib/backup/notifier/twitter.rb +70 -0
- data/lib/backup/package.rb +47 -0
- data/lib/backup/packager.rb +100 -0
- data/lib/backup/pipeline.rb +110 -0
- data/lib/backup/splitter.rb +75 -0
- data/lib/backup/storage/base.rb +99 -0
- data/lib/backup/storage/cloudfiles.rb +87 -0
- data/lib/backup/storage/cycler.rb +117 -0
- data/lib/backup/storage/dropbox.rb +178 -0
- data/lib/backup/storage/ftp.rb +119 -0
- data/lib/backup/storage/local.rb +82 -0
- data/lib/backup/storage/ninefold.rb +116 -0
- data/lib/backup/storage/rsync.rb +149 -0
- data/lib/backup/storage/s3.rb +94 -0
- data/lib/backup/storage/scp.rb +99 -0
- data/lib/backup/storage/sftp.rb +108 -0
- data/lib/backup/syncer/base.rb +46 -0
- data/lib/backup/syncer/cloud/base.rb +247 -0
- data/lib/backup/syncer/cloud/cloud_files.rb +78 -0
- data/lib/backup/syncer/cloud/s3.rb +68 -0
- data/lib/backup/syncer/rsync/base.rb +49 -0
- data/lib/backup/syncer/rsync/local.rb +55 -0
- data/lib/backup/syncer/rsync/pull.rb +36 -0
- data/lib/backup/syncer/rsync/push.rb +116 -0
- data/lib/backup/template.rb +46 -0
- data/lib/backup/version.rb +43 -0
- data/spec-live/.gitignore +6 -0
- data/spec-live/README +7 -0
- data/spec-live/backups/config.rb +83 -0
- data/spec-live/backups/config.yml.template +46 -0
- data/spec-live/backups/models.rb +184 -0
- data/spec-live/compressor/custom_spec.rb +30 -0
- data/spec-live/compressor/gzip_spec.rb +30 -0
- data/spec-live/encryptor/gpg_keys.rb +239 -0
- data/spec-live/encryptor/gpg_spec.rb +287 -0
- data/spec-live/notifier/mail_spec.rb +121 -0
- data/spec-live/spec_helper.rb +151 -0
- data/spec-live/storage/dropbox_spec.rb +151 -0
- data/spec-live/storage/local_spec.rb +83 -0
- data/spec-live/storage/scp_spec.rb +193 -0
- data/spec-live/syncer/cloud/s3_spec.rb +124 -0
- data/spec/archive_spec.rb +335 -0
- data/spec/cleaner_spec.rb +312 -0
- data/spec/cli/helpers_spec.rb +301 -0
- data/spec/cli/utility_spec.rb +411 -0
- data/spec/compressor/base_spec.rb +52 -0
- data/spec/compressor/bzip2_spec.rb +217 -0
- data/spec/compressor/custom_spec.rb +106 -0
- data/spec/compressor/gzip_spec.rb +217 -0
- data/spec/compressor/lzma_spec.rb +123 -0
- data/spec/compressor/pbzip2_spec.rb +165 -0
- data/spec/config_spec.rb +321 -0
- data/spec/configuration/helpers_spec.rb +247 -0
- data/spec/configuration/store_spec.rb +39 -0
- data/spec/configuration_spec.rb +62 -0
- data/spec/database/base_spec.rb +63 -0
- data/spec/database/mongodb_spec.rb +510 -0
- data/spec/database/mysql_spec.rb +411 -0
- data/spec/database/postgresql_spec.rb +353 -0
- data/spec/database/redis_spec.rb +334 -0
- data/spec/database/riak_spec.rb +176 -0
- data/spec/dependency_spec.rb +51 -0
- data/spec/encryptor/base_spec.rb +40 -0
- data/spec/encryptor/gpg_spec.rb +909 -0
- data/spec/encryptor/open_ssl_spec.rb +148 -0
- data/spec/errors_spec.rb +306 -0
- data/spec/hooks_spec.rb +35 -0
- data/spec/logger_spec.rb +367 -0
- data/spec/model_spec.rb +694 -0
- data/spec/notifier/base_spec.rb +104 -0
- data/spec/notifier/campfire_spec.rb +217 -0
- data/spec/notifier/hipchat_spec.rb +211 -0
- data/spec/notifier/mail_spec.rb +316 -0
- data/spec/notifier/prowl_spec.rb +138 -0
- data/spec/notifier/pushover_spec.rb +123 -0
- data/spec/notifier/twitter_spec.rb +153 -0
- data/spec/package_spec.rb +61 -0
- data/spec/packager_spec.rb +213 -0
- data/spec/pipeline_spec.rb +259 -0
- data/spec/spec_helper.rb +60 -0
- data/spec/splitter_spec.rb +120 -0
- data/spec/storage/base_spec.rb +166 -0
- data/spec/storage/cloudfiles_spec.rb +254 -0
- data/spec/storage/cycler_spec.rb +247 -0
- data/spec/storage/dropbox_spec.rb +480 -0
- data/spec/storage/ftp_spec.rb +271 -0
- data/spec/storage/local_spec.rb +259 -0
- data/spec/storage/ninefold_spec.rb +343 -0
- data/spec/storage/rsync_spec.rb +362 -0
- data/spec/storage/s3_spec.rb +245 -0
- data/spec/storage/scp_spec.rb +233 -0
- data/spec/storage/sftp_spec.rb +244 -0
- data/spec/syncer/base_spec.rb +109 -0
- data/spec/syncer/cloud/base_spec.rb +515 -0
- data/spec/syncer/cloud/cloud_files_spec.rb +181 -0
- data/spec/syncer/cloud/s3_spec.rb +174 -0
- data/spec/syncer/rsync/base_spec.rb +98 -0
- data/spec/syncer/rsync/local_spec.rb +149 -0
- data/spec/syncer/rsync/pull_spec.rb +98 -0
- data/spec/syncer/rsync/push_spec.rb +333 -0
- data/spec/version_spec.rb +21 -0
- data/templates/cli/utility/archive +25 -0
- data/templates/cli/utility/compressor/bzip2 +4 -0
- data/templates/cli/utility/compressor/custom +11 -0
- data/templates/cli/utility/compressor/gzip +4 -0
- data/templates/cli/utility/compressor/lzma +10 -0
- data/templates/cli/utility/compressor/pbzip2 +10 -0
- data/templates/cli/utility/config +32 -0
- data/templates/cli/utility/database/mongodb +18 -0
- data/templates/cli/utility/database/mysql +21 -0
- data/templates/cli/utility/database/postgresql +17 -0
- data/templates/cli/utility/database/redis +16 -0
- data/templates/cli/utility/database/riak +11 -0
- data/templates/cli/utility/encryptor/gpg +27 -0
- data/templates/cli/utility/encryptor/openssl +9 -0
- data/templates/cli/utility/model.erb +23 -0
- data/templates/cli/utility/notifier/campfire +12 -0
- data/templates/cli/utility/notifier/hipchat +15 -0
- data/templates/cli/utility/notifier/mail +22 -0
- data/templates/cli/utility/notifier/prowl +11 -0
- data/templates/cli/utility/notifier/pushover +11 -0
- data/templates/cli/utility/notifier/twitter +13 -0
- data/templates/cli/utility/splitter +7 -0
- data/templates/cli/utility/storage/cloud_files +22 -0
- data/templates/cli/utility/storage/dropbox +20 -0
- data/templates/cli/utility/storage/ftp +12 -0
- data/templates/cli/utility/storage/local +7 -0
- data/templates/cli/utility/storage/ninefold +9 -0
- data/templates/cli/utility/storage/rsync +11 -0
- data/templates/cli/utility/storage/s3 +19 -0
- data/templates/cli/utility/storage/scp +11 -0
- data/templates/cli/utility/storage/sftp +11 -0
- data/templates/cli/utility/syncer/cloud_files +46 -0
- data/templates/cli/utility/syncer/rsync_local +12 -0
- data/templates/cli/utility/syncer/rsync_pull +17 -0
- data/templates/cli/utility/syncer/rsync_push +17 -0
- data/templates/cli/utility/syncer/s3 +43 -0
- data/templates/general/links +11 -0
- data/templates/general/version.erb +2 -0
- data/templates/notifier/mail/failure.erb +9 -0
- data/templates/notifier/mail/success.erb +7 -0
- data/templates/notifier/mail/warning.erb +9 -0
- data/templates/storage/dropbox/authorization_url.erb +6 -0
- data/templates/storage/dropbox/authorized.erb +4 -0
- data/templates/storage/dropbox/cache_file_written.erb +10 -0
- metadata +277 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# RubyGems Source
|
4
|
+
source 'http://rubygems.org'
|
5
|
+
|
6
|
+
# Include gem dependencies from the gemspec for development purposes
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
# Dynamically define the dependencies specified in Backup::Dependency.all
|
10
|
+
require File.expand_path("../lib/backup/dependency", __FILE__)
|
11
|
+
Backup::Dependency.all.each do |name, gemspec|
|
12
|
+
gem(name, gemspec[:version])
|
13
|
+
end
|
14
|
+
|
15
|
+
# Define gems to be used in the 'test' environment
|
16
|
+
group :test do
|
17
|
+
gem 'rspec'
|
18
|
+
gem 'mocha', '0.12.7'
|
19
|
+
gem 'timecop'
|
20
|
+
gem 'fuubar'
|
21
|
+
|
22
|
+
gem 'guard'
|
23
|
+
gem 'guard-rspec'
|
24
|
+
gem 'rb-fsevent' # guard notifications for osx
|
25
|
+
gem 'growl' # $ brew install growlnotify
|
26
|
+
gem 'rb-inotify' # guard notifications for linux
|
27
|
+
gem 'libnotify' # $ apt-get install ???
|
28
|
+
end
|
data/Guardfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# To run the test suite against all 3 rubies: 1.9.3, 1.9.2, and 1.8.7, simply run the following command:
|
4
|
+
#
|
5
|
+
# $ guard start
|
6
|
+
#
|
7
|
+
# Be use you are using RVM and have Ruby 1.9.3, 1.9.2, 1.8.7 installed as well as all of Backup's gem
|
8
|
+
# dependencies for each of these Ruby versions.
|
9
|
+
#
|
10
|
+
# Be sure to run `bundle install` against every Ruby version, as well as `gem install thor POpen4`
|
11
|
+
|
12
|
+
guard "rspec",
|
13
|
+
:rvm => ["1.9.3", "1.9.2", "1.8.7"],
|
14
|
+
:cli => "--color --format Fuubar",
|
15
|
+
:notification => false,
|
16
|
+
:all_after_pass => false,
|
17
|
+
:all_on_start => false do
|
18
|
+
|
19
|
+
watch("lib/backup.rb") { "spec" }
|
20
|
+
watch("spec/spec_helper.rb") { "spec" }
|
21
|
+
watch(%r{^lib/backup/(.+)\.rb}) {|m| "spec/#{ m[1] }_spec.rb" }
|
22
|
+
watch(%r{^spec/.+_spec\.rb})
|
23
|
+
end
|
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
ADDED
@@ -0,0 +1,478 @@
|
|
1
|
+
Backup
|
2
|
+
======
|
3
|
+
|
4
|
+
Backup is a RubyGem, written for Linux and Mac OSX, that allows you to easily perform backup operations on both your remote and local environments. It provides you with an elegant DSL in Ruby for modeling 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
|
+
|
6
|
+
[![Build Status](https://secure.travis-ci.org/meskyanichi/backup.png)](http://travis-ci.org/meskyanichi/backup)
|
7
|
+
[![Still Maintained](http://stillmaintained.com/meskyanichi/backup.png)](http://stillmaintained.com/meskyanichi/backup)
|
8
|
+
|
9
|
+
|
10
|
+
### Author
|
11
|
+
|
12
|
+
**[Michael van Rooijen](http://michaelvanrooijen.com/) ( [@meskyanichi](http://twitter.com/#!/meskyanichi) )**
|
13
|
+
|
14
|
+
Drop me a message for any questions, suggestions, requests, bugs or submit them to the [issue log](https://github.com/meskyanichi/backup/issues).
|
15
|
+
|
16
|
+
|
17
|
+
### Installation
|
18
|
+
|
19
|
+
To get the latest stable version
|
20
|
+
|
21
|
+
gem install backup
|
22
|
+
|
23
|
+
You can view the list of released versions over at [RubyGems.org (Backup)](https://rubygems.org/gems/backup/versions)
|
24
|
+
|
25
|
+
|
26
|
+
### Getting Started
|
27
|
+
|
28
|
+
I recommend you read this README first, and refer to the [wiki pages](https://github.com/meskyanichi/backup/wiki) afterwards. There's also a [Getting Started wiki page](https://github.com/meskyanichi/backup/wiki/Getting-Started).
|
29
|
+
|
30
|
+
What Backup 3 currently supports
|
31
|
+
--------------------------------
|
32
|
+
|
33
|
+
Below you find a list of components that Backup currently supports. If you'd like support for components other than the ones listed here, feel free to request them or to fork Backup and add them yourself. Backup is modular and easy to extend.
|
34
|
+
|
35
|
+
### Database Support
|
36
|
+
|
37
|
+
- MySQL
|
38
|
+
- PostgreSQL
|
39
|
+
- MongoDB
|
40
|
+
- Redis
|
41
|
+
- Riak
|
42
|
+
|
43
|
+
[Database Wiki Page](https://github.com/meskyanichi/backup/wiki/Databases)
|
44
|
+
|
45
|
+
### Filesystem Support
|
46
|
+
|
47
|
+
- Files
|
48
|
+
- Directories
|
49
|
+
|
50
|
+
[Archive Wiki Page](https://github.com/meskyanichi/backup/wiki/Archives)
|
51
|
+
|
52
|
+
### Storage Locations and Services
|
53
|
+
|
54
|
+
- Amazon Simple Storage Service (S3)
|
55
|
+
- Rackspace Cloud Files (Mosso)
|
56
|
+
- Ninefold Cloud Storage
|
57
|
+
- Dropbox Web Service
|
58
|
+
- Remote Servers *(Available Protocols: FTP, SFTP, SCP and RSync)*
|
59
|
+
- Local Storage
|
60
|
+
|
61
|
+
[Storage Wiki Page](https://github.com/meskyanichi/backup/wiki/Storages)
|
62
|
+
|
63
|
+
### Storage Features
|
64
|
+
|
65
|
+
- **Backup Cycling, applies to:**
|
66
|
+
- Amazon Simple Storage Service (S3)
|
67
|
+
- Rackspace Cloud Files (Mosso)
|
68
|
+
- Ninefold Cloud Storage
|
69
|
+
- Dropbox Web Service
|
70
|
+
- Remote Servers *(Only Protocols: FTP, SFTP, SCP)*
|
71
|
+
- Local Storage
|
72
|
+
|
73
|
+
[Cycling Wiki Page](https://github.com/meskyanichi/backup/wiki/Cycling)
|
74
|
+
|
75
|
+
- **Backup Splitting, applies to:**
|
76
|
+
- Amazon Simple Storage Service (S3)
|
77
|
+
- Rackspace Cloud Files (Mosso)
|
78
|
+
- Ninefold Cloud Storage
|
79
|
+
- Dropbox Web Service
|
80
|
+
- Remote Servers *(Only Protocols: FTP, SFTP, SCP)*
|
81
|
+
- Local Storage
|
82
|
+
|
83
|
+
[Splitter Wiki Page](https://github.com/meskyanichi/backup/wiki/Splitter)
|
84
|
+
|
85
|
+
- **Incremental Backups, applies to:**
|
86
|
+
- Remote Servers *(Only Protocols: RSync)*
|
87
|
+
|
88
|
+
### Syncers
|
89
|
+
|
90
|
+
- RSync (Push, Pull and Local)
|
91
|
+
- Amazon S3
|
92
|
+
- Rackspce Cloud Files
|
93
|
+
|
94
|
+
[Syncer Wiki Page](https://github.com/meskyanichi/backup/wiki/Syncers)
|
95
|
+
|
96
|
+
### Compressors
|
97
|
+
|
98
|
+
- Gzip
|
99
|
+
- Bzip2
|
100
|
+
- Pbzip2
|
101
|
+
- Lzma
|
102
|
+
|
103
|
+
[Compressors Wiki Page](https://github.com/meskyanichi/backup/wiki/Compressors)
|
104
|
+
|
105
|
+
### Encryptors
|
106
|
+
|
107
|
+
- OpenSSL
|
108
|
+
- GPG
|
109
|
+
|
110
|
+
[Encryptors Wiki Page](https://github.com/meskyanichi/backup/wiki/Encryptors)
|
111
|
+
|
112
|
+
### Notifiers
|
113
|
+
|
114
|
+
- Mail
|
115
|
+
- Twitter
|
116
|
+
- Campfire
|
117
|
+
- Presently
|
118
|
+
- Prowl
|
119
|
+
- Hipchat
|
120
|
+
- Pushover
|
121
|
+
|
122
|
+
[Notifiers Wiki Page](https://github.com/meskyanichi/backup/wiki/Notifiers)
|
123
|
+
|
124
|
+
### Supported Ruby versions (Tested with RSpec)
|
125
|
+
|
126
|
+
- Ruby 1.9.3
|
127
|
+
- Ruby 1.9.2
|
128
|
+
- Ruby 1.8.7
|
129
|
+
|
130
|
+
|
131
|
+
A sample Backup configuration file
|
132
|
+
----------------------------------
|
133
|
+
|
134
|
+
This is a Backup configuration file. Check it out and read the explanation below.
|
135
|
+
Backup has a [great wiki](https://github.com/meskyanichi/backup/wiki) which explains each component of Backup in detail.
|
136
|
+
|
137
|
+
``` rb
|
138
|
+
Backup::Model.new(:sample_backup, 'A sample backup configuration') do
|
139
|
+
|
140
|
+
split_into_chunks_of 4000
|
141
|
+
|
142
|
+
database MySQL do |database|
|
143
|
+
database.name = 'my_sample_mysql_db'
|
144
|
+
database.username = 'my_username'
|
145
|
+
database.password = 'my_password'
|
146
|
+
database.skip_tables = ['logs']
|
147
|
+
database.additional_options = ['--single-transaction', '--quick']
|
148
|
+
end
|
149
|
+
|
150
|
+
database MongoDB do |database|
|
151
|
+
database.name = 'my_sample_mongo_db'
|
152
|
+
database.only_collections = ['users', 'events', 'posts']
|
153
|
+
end
|
154
|
+
|
155
|
+
archive :user_avatars do |archive|
|
156
|
+
archive.add '/var/apps/my_sample_app/public/avatars'
|
157
|
+
end
|
158
|
+
|
159
|
+
archive :logs do |archive|
|
160
|
+
archive.add '/var/apps/my_sample_app/logs/production.log'
|
161
|
+
archive.add '/var/apps/my_sample_app/logs/newrelic_agent.log'
|
162
|
+
archive.add '/var/apps/my_sample_app/logs/other/'
|
163
|
+
archive.exclude '/var/apps/my_sample_app/logs/other/exclude-this.log'
|
164
|
+
end
|
165
|
+
|
166
|
+
encrypt_with OpenSSL do |encryption|
|
167
|
+
encryption.password = 'my_secret_password'
|
168
|
+
end
|
169
|
+
|
170
|
+
compress_with Gzip
|
171
|
+
|
172
|
+
store_with SFTP, "Server A" do |server|
|
173
|
+
server.username = 'my_username'
|
174
|
+
server.password = 'secret'
|
175
|
+
server.ip = 'a.my-backup-server.com'
|
176
|
+
server.port = 22
|
177
|
+
server.path = '~/backups'
|
178
|
+
server.keep = 25
|
179
|
+
end
|
180
|
+
|
181
|
+
store_with SFTP, "Server B" do |server|
|
182
|
+
server.username = 'my_username'
|
183
|
+
server.password = 'secret'
|
184
|
+
server.ip = 'b.my-backup-server.com'
|
185
|
+
server.port = 22
|
186
|
+
server.path = '~/backups'
|
187
|
+
server.keep = 25
|
188
|
+
end
|
189
|
+
|
190
|
+
store_with S3 do |s3|
|
191
|
+
s3.access_key_id = 'my_access_key_id'
|
192
|
+
s3.secret_access_key = 'my_secret_access_key'
|
193
|
+
s3.region = 'us-east-1'
|
194
|
+
s3.bucket = 'my_bucket/backups'
|
195
|
+
s3.keep = 20
|
196
|
+
end
|
197
|
+
|
198
|
+
sync_with Cloud::S3 do |s3|
|
199
|
+
s3.access_key_id = "my_access_key_id"
|
200
|
+
s3.secret_access_key = "my_secret_access_key"
|
201
|
+
s3.bucket = "my-bucket"
|
202
|
+
s3.path = "/backups"
|
203
|
+
s3.mirror = true
|
204
|
+
|
205
|
+
s3.directories do |directory|
|
206
|
+
directory.add "/var/apps/my_app/public/videos"
|
207
|
+
directory.add "/var/apps/my_app/public/music"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
notify_by Mail do |mail|
|
212
|
+
mail.on_success = false
|
213
|
+
mail.on_warning = true
|
214
|
+
mail.on_failure = true
|
215
|
+
end
|
216
|
+
|
217
|
+
notify_by Twitter do |tweet|
|
218
|
+
tweet.on_success = true
|
219
|
+
tweet.on_warning = true
|
220
|
+
tweet.on_failure = true
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
```
|
225
|
+
|
226
|
+
### Brief explanation for the above example configuration
|
227
|
+
|
228
|
+
First, it will dump the two Databases (MySQL and MongoDB). The MySQL dump will be piped through the Gzip Compressor into
|
229
|
+
`sample_backup/databases/MySQL/my_sample_mysql_db.sql.gz`. The MongoDB dump will be dumped into
|
230
|
+
`sample_backup/databases/MongoDB/`, which will then be packaged into `sample_backup/databases/MongoDB-#####.tar.gz`
|
231
|
+
(`#####` will be a simple unique identifier, in case multiple dumps are performed.)
|
232
|
+
Next, it will create two _tar_ Archives (user\_avatars and logs). Each will be piped through the Gzip Compressor into
|
233
|
+
`sample_backup/archives/` as `user_archives.tar.gz` and `logs.tar.gz`.
|
234
|
+
Finally, the `sample_backup` directory will be packaged into an uncompressed _tar_ archive, which will be piped through
|
235
|
+
the OpenSSL Encryptor to encrypt this final package into `YYYY-MM-DD-hh-mm-ss.sample_backup.tar.enc`. This final
|
236
|
+
encrypted archive will then be transfered to your Amazon S3 account. If all goes well, and no exceptions are raised,
|
237
|
+
you'll be notified via the Twitter notifier that the backup succeeded. If any warnings were issued or there was an
|
238
|
+
exception raised during the backup process, then you'd receive an email in your inbox containing detailed exception
|
239
|
+
information, as well as receive a simple Twitter message that something went wrong.
|
240
|
+
|
241
|
+
Aside of S3, we have also defined two `SFTP` storage methods, and given them two unique identifiers `Server A` and
|
242
|
+
`Server B` to distinguish between the two. With these in place, a copy of the backup will now also be stored on two
|
243
|
+
separate servers: `a.my-backup-server.com` and `b.my-backup-server.com`.
|
244
|
+
|
245
|
+
As you can see, you can freely mix and match **archives**, **databases**, **compressors**, **encryptors**, **storages**
|
246
|
+
and **notifiers** for your backups. You could even specify 4 storage locations if you wanted: Amazon S3, Rackspace Cloud
|
247
|
+
Files, Ninefold and Dropbox, it'd then store your packaged backup to 4 separate locations for high redundancy.
|
248
|
+
|
249
|
+
Also, notice the `split_into_chunks_of 4000` at the top of the configuration. This tells Backup to split any backups
|
250
|
+
that exceed in 4000 MEGABYTES of size in to multiple smaller chunks. Assuming your backup file is 12000 MEGABYTES (12GB)
|
251
|
+
in size, then Backup will take the output which was piped from _tar_ into the OpenSSL Compressor and additionally pipe
|
252
|
+
that output through the _split_ utility, which will result in 3 chunks of 4000 MEGABYTES with additional file extensions
|
253
|
+
of `-aa`, `-ab` and `-ac`. These files will then be individually transfered. This is useful for when you are using
|
254
|
+
Amazon S3, Rackspace Cloud Files, or other 3rd party storage services which limit you to "5GB per file" uploads. So with
|
255
|
+
this, the backup file size is no longer a constraint.
|
256
|
+
|
257
|
+
Additionally we have also defined a **S3 Syncer** ( `sync_with Cloud::S3` ), which does not follow the above process of
|
258
|
+
archiving/compression/encryption, but instead will directly sync the whole `videos` and `music` folder structures from
|
259
|
+
your machine to your Amazon S3 account. (very efficient and cost-effective since it will only transfer files that were
|
260
|
+
added/changed. Additionally, since we flagged it to 'mirror', it'll also remove files from S3 that no longer exist). If
|
261
|
+
you simply wanted to sync to a separate backup server that you own, you could also use the RSync syncer for even more
|
262
|
+
efficient backups that only transfer the **bytes** of each file that changed.
|
263
|
+
|
264
|
+
There are more **archives**, **databases**, **compressors**, **encryptors**, **storages** and **notifiers** than
|
265
|
+
displayed in the example, all available components are listed at the top of this README, as well as in the
|
266
|
+
[Wiki](https://github.com/meskyanichi/backup/wiki) with more detailed information.
|
267
|
+
|
268
|
+
### Running the example
|
269
|
+
|
270
|
+
Notice the `Backup::Model.new(:sample_backup, 'A sample backup configuration') do` at the top of the above example. The
|
271
|
+
`:sample_backup` is called the **trigger**. This is used to identify the backup procedure/file and initialize it.
|
272
|
+
|
273
|
+
``` sh
|
274
|
+
backup perform -t [--trigger] sample_backup
|
275
|
+
```
|
276
|
+
|
277
|
+
Now it'll run the backup, it's as simple as that.
|
278
|
+
|
279
|
+
### Automatic backups
|
280
|
+
|
281
|
+
Since Backup is an easy-to-use command line utility, you should write a crontask to invoke it periodically. I recommend
|
282
|
+
using [Whenever](https://github.com/javan/whenever) to manage your crontab. It'll allow you to write to the crontab
|
283
|
+
using pure Ruby, and it provides an elegant DSL to do so. Here's an example:
|
284
|
+
|
285
|
+
``` rb
|
286
|
+
every 6.hours do
|
287
|
+
command "backup perform --trigger sample_backup"
|
288
|
+
end
|
289
|
+
```
|
290
|
+
|
291
|
+
With this in place, run `whenever --update-crontab backup` to write the equivalent of the above Ruby syntax to the
|
292
|
+
crontab in cron-syntax. Cron will now invoke `backup perform --trigger sample_backup` every 6 hours. Check out the
|
293
|
+
Whenever project page for more information.
|
294
|
+
|
295
|
+
### Documentation
|
296
|
+
|
297
|
+
See the [Wiki Pages](https://github.com/meskyanichi/backup/wiki).
|
298
|
+
|
299
|
+
|
300
|
+
### Suggestions, Bugs, Requests, Questions
|
301
|
+
|
302
|
+
View the [issue log](https://github.com/meskyanichi/backup/issues) and post them there.
|
303
|
+
|
304
|
+
### Contributors
|
305
|
+
|
306
|
+
<table>
|
307
|
+
<tr>
|
308
|
+
<th>Contributor</th>
|
309
|
+
<th>Contribution</th>
|
310
|
+
</tr>
|
311
|
+
<tr>
|
312
|
+
<td><a href="https://github.com/burns" target="_blank"><b>Brian D. Burns ( burns )</b></a></td>
|
313
|
+
<td><b>Core Contributor</b></td>
|
314
|
+
</tr>
|
315
|
+
<tr>
|
316
|
+
<td><a href="https://github.com/asanghi" target="_blank">Aditya Sanghi ( asanghi )</a></td>
|
317
|
+
<td>Twitter Notifier, Dropbox Timeout Configuration</td>
|
318
|
+
</tr>
|
319
|
+
<tr>
|
320
|
+
<td><a href="https://github.com/phlipper" target="_blank">Phil Cohen ( phlipper )</a></td>
|
321
|
+
<td>Exclude Option for Archives</td>
|
322
|
+
</tr>
|
323
|
+
<tr>
|
324
|
+
<td><a href="https://github.com/arunagw" target="_blank">Arun Agrawal ( arunagw )</a></td>
|
325
|
+
<td>Campfire notifier</td>
|
326
|
+
</tr>
|
327
|
+
<tr>
|
328
|
+
<td><a href="https://github.com/szimmermann" target="_blank">Stefan Zimmermann ( szimmermann )</a></td>
|
329
|
+
<td>Enabling package/archive (tar utility) support for more Linux distro's (FreeBSD, etc)</td>
|
330
|
+
</tr>
|
331
|
+
<tr>
|
332
|
+
<td><a href="https://github.com/trystant" target="_blank">Mark Nyon ( trystant )</a></td>
|
333
|
+
<td>Helping discuss MongoDump Lock/FSync problem</td>
|
334
|
+
</tr>
|
335
|
+
<tr>
|
336
|
+
<td><a href="https://github.com/imanel" target="_blank">Bernard Potocki ( imanel )</a></td>
|
337
|
+
<td>Helping discuss MongoDump Lock/FSync problem + Submitting a patch</td>
|
338
|
+
</tr>
|
339
|
+
<tr>
|
340
|
+
<td><a href="https://github.com/tomash" target="_blank">Tomasz Stachewicz ( tomash )</a></td>
|
341
|
+
<td>Helping discuss MongoDump Lock/FSync problem + Submitting a patch</td>
|
342
|
+
</tr>
|
343
|
+
<tr>
|
344
|
+
<td><a href="https://github.com/lapluviosilla" target="_blank">Paul Strong ( lapluviosilla )</a></td>
|
345
|
+
<td>Helping discuss MongoDump Lock/FSync problem</td>
|
346
|
+
</tr>
|
347
|
+
<tr>
|
348
|
+
<td><a href="https://github.com/rgnitz" target="_blank">Ryan ( rgnitz )</a></td>
|
349
|
+
<td>Helping discuss MongoDump Lock/FSync problem</td>
|
350
|
+
</tr>
|
351
|
+
<tr>
|
352
|
+
<td><a href="https://github.com/tsigo" target="_blank">Robert Speicher ( tsigo )</a></td>
|
353
|
+
<td>Adding the --quiet [-q] feature to Backup to silence console logging</td>
|
354
|
+
</tr>
|
355
|
+
<tr>
|
356
|
+
<td><a href="https://github.com/jwhitcraft" target="_blank">Jon Whitcraft ( jwhitcraft )</a></td>
|
357
|
+
<td>Adding the ability to add additional options to the S3Syncer</td>
|
358
|
+
</tr>
|
359
|
+
<tr>
|
360
|
+
<td><a href="https://github.com/bgarret" target="_blank">Benoit Garret ( bgarret )</a></td>
|
361
|
+
<td>Presently notifier</td>
|
362
|
+
</tr>
|
363
|
+
<tr>
|
364
|
+
<td><a href="https://github.com/lleirborras" target="_blank">Lleïr Borràs Metje ( lleirborras )</a></td>
|
365
|
+
<td>Lzma Compressor</td>
|
366
|
+
</tr>
|
367
|
+
<tr>
|
368
|
+
<td><a href="https://github.com/jof" target="_blank">Jonathan Lassoff ( jof )</a></td>
|
369
|
+
<td>Bugfixes and more secure GPG storage</td>
|
370
|
+
</tr>
|
371
|
+
<tr>
|
372
|
+
<td><a href="https://github.com/mikz" target="_blank">Michal Cichra ( mikz )</a></td>
|
373
|
+
<td>Wildcard Triggers</td>
|
374
|
+
</tr>
|
375
|
+
<tr>
|
376
|
+
<td><a href="https://github.com/trybeee" target="_blank">Dmitry Novotochinov ( trybeee )</a></td>
|
377
|
+
<td>Dropbox Storage</td>
|
378
|
+
</tr>
|
379
|
+
<tr>
|
380
|
+
<td><a href="https://github.com/Emerson" target="_blank">Emerson Lackey ( Emerson )</a></td>
|
381
|
+
<td>Local RSync Storage</td>
|
382
|
+
</tr>
|
383
|
+
<tr>
|
384
|
+
<td><a href="https://github.com/digilord" target="_blank">digilord</a></td>
|
385
|
+
<td>OpenSSL Verify Mode for Mail Notifier</td>
|
386
|
+
</tr>
|
387
|
+
<tr>
|
388
|
+
<td><a href="https://github.com/stemps" target="_blank">stemps</a></td>
|
389
|
+
<td>FTP Passive Mode</td>
|
390
|
+
</tr>
|
391
|
+
<tr>
|
392
|
+
<td><a href="https://github.com/dkowis" target="_blank">David Kowis ( dkowis )</a></td>
|
393
|
+
<td>Fixed PostgreSQL Password issues</td>
|
394
|
+
</tr>
|
395
|
+
<tr>
|
396
|
+
<td><a href="https://github.com/jotto" target="_blank">Jonathan Otto ( jotto )</a></td>
|
397
|
+
<td>Allow for running PostgreSQL as another UNIX user</td>
|
398
|
+
</tr>
|
399
|
+
<tr>
|
400
|
+
<td><a href="https://github.com/joaovitor" target="_blank">João Vitor ( joaovitor )</a></td>
|
401
|
+
<td>Changed default PostgreSQL example options to appropriate ones</td>
|
402
|
+
</tr>
|
403
|
+
<tr>
|
404
|
+
<td><a href="https://github.com/swissmanu" target="_blank">Manuel Alabor ( swissmanu )</a></td>
|
405
|
+
<td>Prowl Notifier</td>
|
406
|
+
</tr>
|
407
|
+
<tr>
|
408
|
+
<td><a href="https://github.com/josephcrim" target="_blank">Joseph Crim ( josephcrim )</a></td>
|
409
|
+
<td>Riak Database, exit() suggestions</td>
|
410
|
+
</tr>
|
411
|
+
<tr>
|
412
|
+
<td><a href="https://github.com/fearoffish" target="_blank">Jamie van Dyke ( fearoffish )</a></td>
|
413
|
+
<td>POpen4 implementation</td>
|
414
|
+
</tr>
|
415
|
+
<tr>
|
416
|
+
<td><a href="https://github.com/hmarr" target="_blank">Harry Marr ( hmarr )</a></td>
|
417
|
+
<td>Auth URL for Rackspace Cloud Files Storage</td>
|
418
|
+
</tr>
|
419
|
+
<tr>
|
420
|
+
<td><a href="https://github.com/manuelmeurer" target="_blank">Manuel Meurer ( manuelmeurer )</a></td>
|
421
|
+
<td>Ensure the storage file (YAML dump) has content before reading it</td>
|
422
|
+
</tr>
|
423
|
+
<tr>
|
424
|
+
<td><a href="https://github.com/jessedearing" target="_blank">Jesse Dearing ( jessedearing )</a></td>
|
425
|
+
<td>Hipchat Notifier</td>
|
426
|
+
</tr>
|
427
|
+
<tr>
|
428
|
+
<td><a href="https://github.com/szymonpk" target="_blank">Szymon ( szymonpk )</a></td>
|
429
|
+
<td>Pbzip2 compressor</td>
|
430
|
+
</tr>
|
431
|
+
<tr>
|
432
|
+
<td><a href="https://github.com/SteveNewson" target="_blank">Steve Newson ( SteveNewson )</a></td>
|
433
|
+
<td>Pushover Notifier</td>
|
434
|
+
</tr>
|
435
|
+
</table>
|
436
|
+
|
437
|
+
|
438
|
+
### Want to contribute?
|
439
|
+
|
440
|
+
- Fork the project
|
441
|
+
- Write RSpec tests, and test against:
|
442
|
+
- Ruby 1.9.3
|
443
|
+
- Ruby 1.9.2
|
444
|
+
- Ruby 1.8.7
|
445
|
+
- Try to keep the overall *structure / design* of the gem the same
|
446
|
+
|
447
|
+
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.
|
448
|
+
|
449
|
+
|
450
|
+
### Easily run tests against all three Ruby versions
|
451
|
+
|
452
|
+
Install [RVM](https://rvm.beginrescueend.com/) and use it to install Ruby 1.9.3, 1.9.2 and 1.8.7.
|
453
|
+
|
454
|
+
rvm get latest && rvm reload
|
455
|
+
rvm install 1.9.3 && rvm install 1.9.2 && rvm install 1.8.7
|
456
|
+
|
457
|
+
Once these are installed, go ahead and install all the necessary dependencies.
|
458
|
+
|
459
|
+
cd backup
|
460
|
+
rvm use 1.9.3 && gem install bundler && bundle install
|
461
|
+
rvm use 1.9.2 && gem install bundler && bundle install
|
462
|
+
rvm use 1.8.7 && gem install bundler && bundle install
|
463
|
+
|
464
|
+
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 four Rubies. If you've done the above, all you have to do is run:
|
465
|
+
|
466
|
+
bundle exec guard
|
467
|
+
|
468
|
+
from Backup's root and that's it. It'll now test against all Ruby versions each time you adjust a file in the `lib` or `spec` directories.
|
469
|
+
|
470
|
+
|
471
|
+
### Or contribute by writing blogs/tutorials/use cases
|
472
|
+
|
473
|
+
- http://freelancing-gods.com/posts/backing_up_with_backup
|
474
|
+
- http://erik.debill.org/2011/03/26/csing-backup-with-rails
|
475
|
+
- http://blog.noizeramp.com/2011/03/31/backing-up-backup-ruby-gem/
|
476
|
+
- http://www.sebaugereau.com/using-ruby-to-backup-with-beauty
|
477
|
+
- http://outofti.me/post/4159686269/backup-with-pgbackups
|
478
|
+
- http://h2ik.co/2011/03/backing-up-with-ruby/
|