backup 3.10.0 → 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d08ea59b9238db092857f8ee08a10f1c695d1705
4
- data.tar.gz: 8030b371b0b43a7ba075927af576265d5ddf8969
3
+ metadata.gz: 90a0ce4d50fcbf5dbc1ff35c6ceb182757b5b1ca
4
+ data.tar.gz: e6cd5b21bed38cd91d97dad2489d38107e33a387
5
5
  SHA512:
6
- metadata.gz: 8f76e9862b4784775aecd53127ebe9c478f378a7162348d88bd2fd5e0b515b144deb89dd89c68d7b4592f0f8d94eda4ac228bee29f204a240ab635038089ed27
7
- data.tar.gz: 13c73bfd31689f46c9f0c809849e59180a1e4eebeb0af05650dae7a8948895f2dc5e80e08c6a67c16a5028fb6b58269be05f49f56d8fc3a7b6782730890a1e3c
6
+ metadata.gz: dfec691ea4ad54ed847451247fbc26d8f476360075becea60416249a22805740284c18c5d5e6e16333dfa344402dd607feaf0d9b147b1763ff3ad580051d165c
7
+ data.tar.gz: d0b6389c651ef00d14833b03830864b90e1c71cdae7dbc17bb6f308d58c4b03c68c716e32c58048a24e442a1ddfcd9087ec801a2b827a9632bdeb18af6965d75
data/README.md CHANGED
@@ -1,235 +1,19 @@
1
- Backup
2
- ======
1
+ Backup v3.x
2
+ ===========
3
3
 
4
4
  Backup is a system utility for Linux and Mac OS X, distributed as a RubyGem, that allows you to easily perform backup
5
5
  operations. It provides an elegant DSL in Ruby for _modeling_ your backups. Backup has built-in support for various
6
6
  databases, storage protocols/services, syncers, compressors, encryptors and notifiers which you can mix and match. It
7
7
  was built with modularity, extensibility and simplicity in mind.
8
8
 
9
- ## Installation
9
+ [Installation][] · [Release Notes][] · [Documentation][]
10
10
 
11
- **_Do not add `gem backup` to an application's `Gemfile`_**
12
11
 
13
- To install the latest version, run:
14
-
15
- $ [sudo] gem install backup
16
-
17
- See [Installation](https://github.com/meskyanichi/backup/wiki/Installation) for more information about installing and
18
- updating your installation of Backup.
19
-
20
- See [Release Notes](https://github.com/meskyanichi/backup/wiki/Release-Notes) for changes in the latest version.
21
-
22
- Backup supports Ruby versions 1.8.7, 1.9.2, 1.9.3 and 2.0.0.
23
-
24
- ## Overview
25
-
26
- Backup allows you to _model_ your backup jobs using a Ruby DSL:
27
-
28
- ```rb
29
- Backup::Model.new(:my_backup, 'Description for my_backup') do
30
- # ... components here ...
31
- end
32
- ```
33
-
34
- The `:my_backup` symbol is the model's `trigger` and used to perform the job:
35
-
36
- $ backup perform --trigger my_backup
37
-
38
- Backup's _components_ are added to the backup _model_ to define the actions to be performed.
39
- All of Backup's components are fully documented in the [Backup Wiki](https://github.com/meskyanichi/backup/wiki).
40
- The following is brief overview of the components Backup provides:
41
-
42
- ### Archives and Databases
43
-
44
- [Archives](https://github.com/meskyanichi/backup/wiki/Archives) create basic `tar` archives. Both **GNU** and **BSD**
45
- `tar` are supported.
46
- [Databases](https://github.com/meskyanichi/backup/wiki/Databases) create backups of one of the following supported databases:
47
-
48
- - MySQL
49
- - PostgreSQL
50
- - MongoDB
51
- - Redis
52
- - Riak
53
-
54
- Any number of Archives and Databases may be defined within a backup _model_.
55
-
56
- ### Compressors and Encryptors
57
-
58
- Adding a [Compressor](https://github.com/meskyanichi/backup/wiki/Compressors) to your backup will compress all the
59
- Archives and Database backups within your final archive package.
60
- `Gzip`, `Bzip2` and other similar compressors are supported.
61
-
62
- Adding a [Encryptor](https://github.com/meskyanichi/backup/wiki/Encryptors) allows you to encrypt your final backup package.
63
- Both `OpenSSL` and `GPG` are supported.
64
-
65
- Your final backup _package_ might look something like this:
66
-
67
- ```text
68
- $ gpg --decrypt my_backup.tar.gpg --outfile my_backup.tar
69
- $ tar -tvf my_backup.tar
70
- my_backup/
71
- my_backup/archives/
72
- my_backup/archives/user_avatars.tar.gz
73
- my_backup/archives/log_files.tar.gz
74
- my_backup/databases/
75
- my_backup/databases/PostgreSQL.sql.gz
76
- my_backup/databases/Redis.rdb.gz
77
- ```
78
-
79
- ### Storages
80
-
81
- Once your final backup package is ready, you can use any number of the following
82
- [Storages](https://github.com/meskyanichi/backup/wiki/Storages) to store it:
83
-
84
- - Amazon Simple Storage Service (S3)
85
- - Rackspace Cloud Files (Mosso)
86
- - Ninefold Cloud Storage
87
- - Dropbox Web Service
88
- - Remote Servers _(Available Protocols: FTP, SFTP, SCP and RSync)_
89
- - Local Storage _(including network mounted locations)_
90
-
91
- All of the above Storages _(except RSync)_ support:
92
-
93
- - [Cycling](https://github.com/meskyanichi/backup/wiki/Cycling) to keep and rotate multiple copies
94
- of your stored backups.
95
-
96
- - [Splitter](https://github.com/meskyanichi/backup/wiki/Splitter) to break up a large
97
- backup package into smaller files.
98
-
99
- When using the RSync Storage, once a full backup has been stored, subsequent backups only need to
100
- transmit the changed portions of the final archive to bring the remote copy up-to-date.
101
-
102
- ### Syncers
103
-
104
- [Syncers](https://github.com/meskyanichi/backup/wiki/Syncers) are processed after your final backup archive has been
105
- stored and allow you to perform file synchronization.
106
-
107
- Backup includes two types of Syncers:
108
-
109
- - `RSync`: Used to sync files locally, local-to-remote (`Push`), or remote-to-local (`Pull`).
110
- - `Cloud`: Used to sync files to remote storage services like Amazon S3 and Rackspace.
111
-
112
- A backup _model_ may contain _only_ Syncers as well.
113
-
114
- ### Notifiers
115
-
116
- [Notifiers](https://github.com/meskyanichi/backup/wiki/Notifiers) are used to send notifications upon successful and/or
117
- failed completion of your backup _model_.
118
-
119
- Supported notification services include:
120
-
121
- - Email _(SMTP, Sendmail, Exim and File delivery)_
122
- - Twitter
123
- - Campfire
124
- - Presently
125
- - Prowl
126
- - Hipchat
127
- - Pushover
128
- - POST Request
129
- - Nagios
130
-
131
-
132
- ## Generators
133
-
134
- Backup makes it easy to setup new backup _model_ files with it's [Generator](https://github.com/meskyanichi/backup/wiki/Generator) command.
135
-
136
- ```
137
- $ backup generate:model -t my_backup --archives --databases=postgresql,redis --compressors=gzip \
138
- --encryptors=gpg --storages=sftp,s3 --notifiers=mail,twitter
139
- ```
140
-
141
- Simply generate a new _model_ using the options you need, then update the configuration for each component using the
142
- [Wiki](https://github.com/meskyanichi/backup/wiki) documentation.
143
-
144
- The following is an example of a what this Backup _model_ might look like:
145
-
146
- ```rb
147
- Backup::Model.new(:my_backup, 'Description for my_backup') do
148
- split_into_chunks_of 250
149
-
150
- archive :user_avatars do |archive|
151
- archive.add '/var/apps/my_sample_app/public/avatars'
152
- end
153
-
154
- archive :log_files do |archive|
155
- archive.add '/var/apps/my_sample_app/logs'
156
- archive.exclude '/var/apps/my_sample_app/logs/exclude-this.log'
157
- end
158
-
159
- database PostgreSQL do |db|
160
- db.name = "pg_db_name"
161
- db.username = "username"
162
- db.password = "password"
163
- end
164
-
165
- database Redis do |db|
166
- db.name = "redis_db_name"
167
- db.path = "/usr/local/var/db/redis"
168
- db.password = "password"
169
- db.invoke_save = true
170
- end
171
-
172
- compress_with Gzip
173
-
174
- encrypt_with GPG do |encryption|
175
- encryption.mode = :symmetric
176
- encryption.passphrase = 'my_password'
177
- end
178
-
179
- store_with SFTP do |server|
180
- server.username = "my_username"
181
- server.password = "my_password"
182
- server.ip = "123.45.678.90"
183
- server.port = 22
184
- server.path = "~/backups/"
185
- server.keep = 5
186
- end
187
-
188
- store_with S3 do |s3|
189
- s3.access_key_id = "my_access_key_id"
190
- s3.secret_access_key = "my_secret_access_key"
191
- s3.region = "us-east-1"
192
- s3.bucket = "bucket-name"
193
- s3.path = "/path/to/my/backups"
194
- s3.keep = 10
195
- end
196
-
197
- notify_by Mail do |mail|
198
- mail.on_success = false
199
-
200
- mail.from = "sender@email.com"
201
- mail.to = "receiver@email.com"
202
- mail.address = "smtp.gmail.com"
203
- mail.port = 587
204
- mail.user_name = "sender@email.com"
205
- mail.password = "my_password"
206
- mail.authentication = "plain"
207
- mail.encryption = :starttls
208
- end
209
-
210
- notify_by Twitter do |tweet|
211
- tweet.consumer_key = "my_consumer_key"
212
- tweet.consumer_secret = "my_consumer_secret"
213
- tweet.oauth_token = "my_oauth_token"
214
- tweet.oauth_token_secret = "my_oauth_token_secret"
215
- end
216
- end
217
- ```
218
-
219
- The [Getting Started](https://github.com/meskyanichi/backup/wiki/Getting-Started) page provides a simple
220
- walk-through to familiarize you with setting up, configuring and running a backup job.
221
-
222
- ## Suggestions, Issues, etc...
223
-
224
- If you have any suggestions or problems, please submit an Issue or Pull Request using Backup's
225
- [Issue Log](https://github.com/meskyanichi/backup/issues).
226
-
227
- If you find any errors or omissions in Backup's documentation [Wiki](https://github.com/meskyanichi/backup/wiki),
228
- please feel free to edit it!
229
-
230
- Backup has seen many improvements over the years thanks to it's
231
- [Contributors](https://github.com/meskyanichi/backup/contributors), as well as those who have help discuss issues and
232
- improve the documentation, and looks forward to continuing to provide users with a reliable backup solution.
233
-
234
- **Copyright (c) 2009-2013 [Michael van Rooijen](http://michaelvanrooijen.com/) ( [@meskyanichi](http://twitter.com/#!/meskyanichi) )**
12
+ **Copyright (c) 2009-2014 [Michael van Rooijen][] ( [@meskyanichi][] )**
235
13
  Released under the **MIT** [License](LICENSE.md).
14
+
15
+ [Installation]: http://meskyanichi.github.io/backup/v3/installation
16
+ [Release Notes]: http://meskyanichi.github.io/backup/v3/release-notes
17
+ [Documentation]: http://meskyanichi.github.io/backup/v3
18
+ [Michael van Rooijen]: http://michaelvanrooijen.com
19
+ [@meskyanichi]: http://twitter.com/#!/meskyanichi
@@ -32,28 +32,48 @@ module Backup
32
32
  attr_accessor :only_tables
33
33
 
34
34
  ##
35
- # Additional "mysqldump" options
35
+ # Additional "mysqldump" or "innobackupex (backup creation)" options
36
36
  attr_accessor :additional_options
37
37
 
38
+ ##
39
+ # Additional innobackupex log preparation phase ("apply-logs") options
40
+ attr_accessor :prepare_options
41
+
42
+ ##
43
+ # Default is :mysqldump (which is built in MySQL and generates
44
+ # a textual SQL file), but can be changed to :innobackupex, which
45
+ # has more feasible restore times for large databases.
46
+ # See: http://www.percona.com/doc/percona-xtrabackup/
47
+ attr_accessor :backup_engine
48
+
49
+ ##
50
+ # If set the backup engine command block is executed as the given user
51
+ attr_accessor :sudo_user
52
+
53
+ ##
54
+ # If set, do not suppress innobackupdb output (useful for debugging)
55
+ attr_accessor :verbose
56
+
38
57
  def initialize(model, database_id = nil, &block)
39
58
  super
40
59
  instance_eval(&block) if block_given?
41
60
 
42
61
  @name ||= :all
62
+ @backup_engine ||= :mysqldump
43
63
  end
44
64
 
45
65
  ##
46
- # Performs the mysqldump command and outputs the dump file
47
- # in the +dump_path+ using +dump_filename+.
66
+ # Performs the mysqldump or innobackupex command and outputs
67
+ # the dump file in the +dump_path+ using +dump_filename+.
48
68
  #
49
- # <trigger>/databases/MySQL[-<database_id>].sql[.gz]
69
+ # <trigger>/databases/MySQL[-<database_id>].[sql|tar][.gz]
50
70
  def perform!
51
71
  super
52
72
 
53
73
  pipeline = Pipeline.new
54
- dump_ext = 'sql'
74
+ dump_ext = sql_backup? ? 'sql' : 'tar'
55
75
 
56
- pipeline << mysqldump
76
+ pipeline << sudo_option(sql_backup? ? mysqldump : innobackupex)
57
77
 
58
78
  model.compressor.compress_with do |command, ext|
59
79
  pipeline << command
@@ -99,6 +119,10 @@ module Backup
99
119
  Array(additional_options).join(' ')
100
120
  end
101
121
 
122
+ def user_prepare_options
123
+ Array(prepare_options).join(' ')
124
+ end
125
+
102
126
  def name_option
103
127
  dump_all? ? '--all-databases' : name
104
128
  end
@@ -130,6 +154,39 @@ module Backup
130
154
  Utilities.configure { mysqldump val }
131
155
  }
132
156
 
157
+ def sql_backup?
158
+ backup_engine.to_sym == :mysqldump
159
+ end
160
+
161
+ def innobackupex
162
+ # Creation phase
163
+ "#{ utility(:innobackupex) } #{ credential_options } " +
164
+ "#{ connectivity_options } #{ user_options } " +
165
+ "--no-timestamp #{ temp_dir } #{ quiet_option } && " +
166
+ # Log applying phase (prepare for restore)
167
+ "#{ utility(:innobackupex) } --apply-log #{ temp_dir } " +
168
+ "#{ user_prepare_options } #{ quiet_option } && " +
169
+ # Move files to tar-ed stream on stdout
170
+ "#{ utility(:tar) } --remove-files -cf - " +
171
+ "-C #{ File.dirname(temp_dir) } #{ File.basename(temp_dir) }"
172
+ end
173
+
174
+ def sudo_option(command_block)
175
+ return command_block unless sudo_user
176
+
177
+ "sudo -s -u #{ sudo_user } -- <<END_OF_SUDO\n" +
178
+ "#{command_block}\n" +
179
+ "END_OF_SUDO\n"
180
+ end
181
+
182
+ def quiet_option
183
+ verbose ? "" : " 2> /dev/null "
184
+ end
185
+
186
+ def temp_dir
187
+ File.join(dump_path, dump_filename + ".bkpdir")
188
+ end
189
+
133
190
  end
134
191
  end
135
192
  end
@@ -8,7 +8,8 @@ module Backup
8
8
  NAMES = %w{
9
9
  tar cat split sudo chown hostname
10
10
  gzip bzip2 lzma pbzip2
11
- mongo mongodump mysqldump pg_dump pg_dumpall redis-cli riak-admin
11
+ mongo mongodump mysqldump innobackupex
12
+ pg_dump pg_dumpall redis-cli riak-admin
12
13
  gpg openssl
13
14
  rsync ssh
14
15
  sendmail exim
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Backup
4
- VERSION = '3.10.0'
4
+ VERSION = '3.11.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-20 00:00:00.000000000 Z
11
+ date: 2014-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -501,17 +501,17 @@ require_paths:
501
501
  - lib
502
502
  required_ruby_version: !ruby/object:Gem::Requirement
503
503
  requirements:
504
- - - '>='
504
+ - - ">="
505
505
  - !ruby/object:Gem::Version
506
506
  version: '0'
507
507
  required_rubygems_version: !ruby/object:Gem::Requirement
508
508
  requirements:
509
- - - '>='
509
+ - - ">="
510
510
  - !ruby/object:Gem::Version
511
511
  version: '0'
512
512
  requirements: []
513
513
  rubyforge_project:
514
- rubygems_version: 2.1.11
514
+ rubygems_version: 2.2.2
515
515
  signing_key:
516
516
  specification_version: 4
517
517
  summary: Provides an elegant DSL in Ruby for performing backups on UNIX-like systems.