backup 3.1.3 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,10 +8,112 @@ module Backup
8
8
  gzip bzip2 lzma pbzip2
9
9
  mongo mongodump mysqldump pg_dump redis-cli riak-admin
10
10
  gpg openssl
11
- rsync
11
+ rsync ssh
12
12
  }
13
13
 
14
- module Helpers
14
+ module DSL
15
+ class << self
16
+ ##
17
+ # Allow users to set the path for all utilities in the .configure block.
18
+ #
19
+ # Utility names with dashes ('redis-cli') will be set using method calls
20
+ # with an underscore ('redis_cli').
21
+ NAMES.each do |name|
22
+ define_method name.gsub('-', '_'), lambda {|val|
23
+ path = File.expand_path(val)
24
+ unless File.executable?(path)
25
+ raise Errors::Utilities::NotFoundError, <<-EOS
26
+ The path given for '#{ name }' was not found or not executable.
27
+ Path was: #{ path }
28
+ EOS
29
+ end
30
+ UTILITY[name] = path
31
+ }
32
+ end
33
+
34
+ ##
35
+ # Allow users to set the +tar+ distribution if needed. (:gnu or :bsd)
36
+ def tar_dist(val)
37
+ Utilities.tar_dist(val)
38
+ end
39
+ end
40
+ end
41
+
42
+ class << self
43
+ ##
44
+ # Configure the path to system utilities used by Backup.
45
+ #
46
+ # Backup will attempt to locate any required system utilities using a
47
+ # +which+ command call. If a utility can not be found, or you need to
48
+ # specify an alternate path for a utility, you may do so in your
49
+ # +config.rb+ file using this method.
50
+ #
51
+ # Backup supports both GNU and BSD utilities.
52
+ # While Backup uses these utilities in a manner compatible with either
53
+ # version, the +tar+ utility requires some special handling with respect
54
+ # to +Archive+s. Backup will attempt to detect if the +tar+ command
55
+ # found (or set here) is GNU or BSD. If for some reason this fails,
56
+ # this may be set using the +tar_dist+ command shown below.
57
+ #
58
+ # Backup::Utilities.configure do
59
+ # # General Utilites
60
+ # tar '/path/to/tar'
61
+ # tar_dist :gnu # or :bsd
62
+ # cat '/path/to/cat'
63
+ # split '/path/to/split'
64
+ # find '/path/to/find'
65
+ # xargs '/path/to/xargs'
66
+ #
67
+ # # Compressors
68
+ # gzip '/path/to/gzip'
69
+ # bzip2 '/path/to/bzip2'
70
+ # lzma '/path/to/lzma' # deprecated. use a Custom Compressor
71
+ # pbzip2 '/path/to/pbzip2' # deprecated. use a Custom Compressor
72
+ #
73
+ # # Database Utilities
74
+ # mongo '/path/to/mongo'
75
+ # mongodump '/path/to/mongodump'
76
+ # mysqldump '/path/to/mysqldump'
77
+ # pg_dump '/path/to/pg_dump'
78
+ # redis_cli '/path/to/redis-cli'
79
+ # riak_admin '/path/to/riak-admin'
80
+ #
81
+ # # Encryptors
82
+ # gpg '/path/to/gpg'
83
+ # openssl '/path/to/openssl'
84
+ #
85
+ # # Syncer and Storage
86
+ # rsync '/path/to/rsync'
87
+ # ssh '/path/to/ssh'
88
+ # end
89
+ #
90
+ # These paths may be set using absolute paths, or relative to the
91
+ # working directory when Backup is run.
92
+ #
93
+ # Note that many of Backup's components currently have their own
94
+ # configuration settings for utility paths. For instance, when configuring
95
+ # a +MySQL+ database backup, +mysqldump_utility+ may be used:
96
+ #
97
+ # database MySQL do |db|
98
+ # db.mysqldump_utility = '/path/to/mysqldump'
99
+ # end
100
+ #
101
+ # Use of these configuration settings will override the path set here.
102
+ # (The use of these may be deprecated in the future)
103
+ def configure(&block)
104
+ DSL.instance_eval(&block)
105
+ end
106
+
107
+ def tar_dist(val)
108
+ # the acceptance tests need to be able to reset this to nil
109
+ @gnu_tar = val.nil? ? nil : val == :gnu
110
+ end
111
+
112
+ def gnu_tar?
113
+ return @gnu_tar unless @gnu_tar.nil?
114
+ @gnu_tar = !!run("#{ utility(:tar) } --version").match(/GNU/)
115
+ end
116
+
15
117
  private
16
118
 
17
119
  ##
@@ -100,112 +202,21 @@ module Backup
100
202
  end
101
203
  end
102
204
 
103
- def gnu_tar?
104
- Utilities.gnu_tar?
105
- end
106
- end # Helpers
107
-
108
- class << self
109
- include Helpers
110
-
111
- ##
112
- # Configure the path to system utilities used by Backup.
113
- #
114
- # Backup will attempt to locate any required system utilities using a
115
- # +which+ command call. If a utility can not be found, or you need to
116
- # specify an alternate path for a utility, you may do so in your
117
- # +config.rb+ file using this method.
118
- #
119
- # Backup supports both GNU and BSD utilities.
120
- # While Backup uses these utilities in a manner compatible with either
121
- # version, the +tar+ utility requires some special handling with respect
122
- # to +Archive+s. Backup will attempt to detect if the +tar+ command
123
- # found (or set here) is GNU or BSD. If for some reason this fails,
124
- # this may be set using the +tar_dist+ command shown below.
125
- #
126
- # Backup::Utilities.configure do
127
- # # General Utilites
128
- # tar '/path/to/tar'
129
- # tar_dist :gnu # or :bsd
130
- # cat '/path/to/cat'
131
- # split '/path/to/split'
132
- # find '/path/to/find'
133
- # xargs '/path/to/xargs'
134
- #
135
- # # Compressors
136
- # gzip '/path/to/gzip'
137
- # bzip2 '/path/to/bzip2'
138
- # lzma '/path/to/lzma' # deprecated. use a Custom Compressor
139
- # pbzip2 '/path/to/pbzip2' # deprecated. use a Custom Compressor
140
- #
141
- # # Database Utilities
142
- # mongo '/path/to/mongo'
143
- # mongodump '/path/to/mongodump'
144
- # mysqldump '/path/to/mysqldump'
145
- # pg_dump '/path/to/pg_dump'
146
- # redis_cli '/path/to/redis-cli'
147
- # riak_admin '/path/to/riak-admin'
148
- #
149
- # # Encryptors
150
- # gpg '/path/to/gpg'
151
- # openssl '/path/to/openssl'
152
- #
153
- # # Syncer and Storage
154
- # rsync '/path/to/rsync'
155
- # end
156
- #
157
- # These paths may be set using absolute paths, or relative to the
158
- # working directory when Backup is run.
159
- #
160
- # Note that many of Backup's components currently have their own
161
- # configuration settings for utility paths. For instance, when configuring
162
- # a +MySQL+ database backup, +mysqldump_utility+ may be used:
163
- #
164
- # database MySQL do |db|
165
- # db.mysqldump_utility = '/path/to/mysqldump'
166
- # end
167
- #
168
- # Use of these configuration settings will override the path set here.
169
- # (The use of these may be deprecated in the future)
170
- def configure(&block)
171
- instance_eval(&block)
172
- end
173
-
174
- def gnu_tar?
175
- return @gnu_tar unless @gnu_tar.nil?
176
- @gnu_tar = !!run("#{ utility(:tar) } --version").match(/GNU/)
177
- end
178
-
179
- private
180
-
181
- ##
182
- # Allow users to set the path for all utilities in the .configure block.
183
- #
184
- # Utility names with dashes ('redis-cli') will be set using method calls
185
- # with an underscore ('redis_cli').
186
- NAMES.each do |name|
187
- define_method name.gsub('-', '_'), lambda {|val|
188
- path = File.expand_path(val)
189
- unless File.executable?(path)
190
- raise Errors::Utilities::NotFoundError, <<-EOS
191
- The path given for '#{ name }' was not found or not executable.
192
- Path was: #{ path }
193
- EOS
194
- end
195
- UTILITY[name] = path
196
- }
197
- end
198
-
199
- ##
200
- # Allow users to set the +tar+ distribution if needed. (:gnu or :bsd)
201
- def tar_dist(val)
202
- @gnu_tar = val == :gnu
203
- end
204
-
205
205
  def reset!
206
206
  UTILITY.clear
207
207
  @gnu_tar = nil
208
208
  end
209
209
  end
210
+
211
+ # Allows these utility methods to be included in other classes,
212
+ # while allowing them to be stubbed in spec_helper for all specs.
213
+ module Helpers
214
+ [:utility, :command_name, :run].each do |name|
215
+ define_method name, lambda {|arg| Utilities.send(name, arg) }
216
+ private name
217
+ end
218
+ private
219
+ def gnu_tar?; Utilities.gnu_tar?; end
220
+ end
210
221
  end
211
222
  end
@@ -13,7 +13,7 @@ module Backup
13
13
  # Defines the minor version
14
14
  # PATCH:
15
15
  # Defines the patch version
16
- MAJOR, MINOR, PATCH = 3, 1, 3
16
+ MAJOR, MINOR, PATCH = 3, 2, 0
17
17
 
18
18
  ##
19
19
  # Returns the major version ( big release based off of multiple minor releases )
@@ -1,21 +1,29 @@
1
1
  ##
2
2
  # Archive [Archive]
3
3
  #
4
- # Adding a file:
4
+ # Adding a file or directory (including sub-directories):
5
5
  # archive.add "/path/to/a/file.rb"
6
- #
7
- # Adding an directory (including sub-directories):
8
6
  # archive.add "/path/to/a/directory/"
9
7
  #
10
- # Excluding a file:
8
+ # Excluding a file or directory (including sub-directories):
11
9
  # archive.exclude "/path/to/an/excluded_file.rb"
10
+ # archive.exclude "/path/to/an/excluded_directory
11
+ #
12
+ # By default, relative paths will be relative to the directory
13
+ # where `backup perform` is executed, and they will be expanded
14
+ # to the root of the filesystem when added to the archive.
15
+ #
16
+ # If a `root` path is set, relative paths will be relative to the
17
+ # given `root` path and will not be expanded when added to the archive.
18
+ #
19
+ # archive.root '/path/to/archive/root'
12
20
  #
13
- # Excluding a directory (including sub-directories):
14
- # archive.exclude "/path/to/an/excluded_directory/
21
+ # For more details, please see:
22
+ # https://github.com/meskyanichi/backup/wiki/Archives
15
23
  #
16
24
  archive :my_archive do |archive|
17
25
  archive.add "/path/to/a/file.rb"
18
26
  archive.add "/path/to/a/folder/"
19
27
  archive.exclude "/path/to/a/excluded_file.rb"
20
- archive.exclude "/path/to/a/excluded_folder/"
28
+ archive.exclude "/path/to/a/excluded_folder"
21
29
  end
@@ -18,5 +18,5 @@
18
18
  mail.user_name = "sender@email.com"
19
19
  mail.password = "my_password"
20
20
  mail.authentication = "plain"
21
- mail.enable_starttls_auto = true
21
+ mail.encryption = :starttls
22
22
  end
@@ -1,11 +1,19 @@
1
1
  ##
2
2
  # RSync [Storage]
3
3
  #
4
- store_with RSync do |server|
5
- server.username = "my_username"
6
- server.password = "my_password"
7
- server.ip = "123.45.678.90"
8
- server.port = 22
9
- server.path = "~/backups/"
10
- server.local = false
4
+ # The default `mode` is :ssh, which does not require the use
5
+ # of an rsync daemon on the remote. If you wish to connect
6
+ # directly to an rsync daemon, or via SSH using daemon features,
7
+ # :rsync_daemon and :ssh_daemon modes are also available.
8
+ #
9
+ # If no `host` is specified, the transfer will be a local
10
+ # operation. `mode` and `compress` will have no meaning.
11
+ #
12
+ # See the documentation on the Wiki for details.
13
+ # https://github.com/meskyanichi/backup/wiki/Storages
14
+ store_with RSync do |rsync|
15
+ rsync.mode = :ssh
16
+ rsync.host = "123.45.678.90"
17
+ rsync.path = "~/backups/"
18
+ rsync.compress = true
11
19
  end
@@ -2,7 +2,7 @@
2
2
  # RSync::Local [Syncer]
3
3
  #
4
4
  sync_with RSync::Local do |rsync|
5
- rsync.path = "~/backups/"
5
+ rsync.path = "~/backups"
6
6
  rsync.mirror = true
7
7
 
8
8
  rsync.directories do |directory|
@@ -1,12 +1,17 @@
1
1
  ##
2
2
  # RSync::Pull [Syncer]
3
3
  #
4
+ # The default `mode` is :ssh, which does not require the use
5
+ # of an rsync daemon on the remote. If you wish to connect
6
+ # directly to an rsync daemon, or via SSH using daemon features,
7
+ # :rsync_daemon and :ssh_daemon modes are also available.
8
+ # See the documentation on the Wiki for details.
9
+ # https://github.com/meskyanichi/backup/wiki/Syncers
10
+ #
4
11
  sync_with RSync::Pull do |rsync|
5
- rsync.ip = "123.45.678.90"
6
- rsync.port = 22
7
- rsync.username = "my_username"
8
- rsync.password = "my_password"
9
- rsync.path = "~/backups/"
12
+ rsync.mode = :ssh
13
+ rsync.host = "123.45.678.90"
14
+ rsync.path = "~/backups"
10
15
  rsync.mirror = true
11
16
  rsync.compress = true
12
17
 
@@ -1,12 +1,17 @@
1
1
  ##
2
2
  # RSync::Push [Syncer]
3
3
  #
4
+ # The default `mode` is :ssh, which does not require the use
5
+ # of an rsync daemon on the remote. If you wish to connect
6
+ # directly to an rsync daemon, or via SSH using daemon features,
7
+ # :rsync_daemon and :ssh_daemon modes are also available.
8
+ # See the documentation on the Wiki for details.
9
+ # https://github.com/meskyanichi/backup/wiki/Syncers
10
+ #
4
11
  sync_with RSync::Push do |rsync|
5
- rsync.ip = "123.45.678.90"
6
- rsync.port = 22
7
- rsync.username = "my_username"
8
- rsync.password = "my_password"
9
- rsync.path = "~/backups/"
12
+ rsync.mode = :ssh
13
+ rsync.host = "123.45.678.90"
14
+ rsync.path = "~/backups"
10
15
  rsync.mirror = true
11
16
  rsync.compress = true
12
17
 
metadata CHANGED
@@ -1,20 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.3
4
+ version: 3.2.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-03-13 00:00:00.000000000 Z
11
+ date: 2013-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.15.4
20
20
  - - <
@@ -24,7 +24,7 @@ dependencies:
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ! '>='
27
+ - - '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: 0.15.4
30
30
  - - <
@@ -177,12 +177,12 @@ require_paths:
177
177
  - lib
178
178
  required_ruby_version: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - ! '>='
180
+ - - '>='
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ! '>='
185
+ - - '>='
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  requirements: []
@@ -192,3 +192,4 @@ signing_key:
192
192
  specification_version: 4
193
193
  summary: Provides an elegant DSL in Ruby for performing backups on UNIX-like systems.
194
194
  test_files: []
195
+ has_rdoc: