Class: Backup::Compressor::Gzip
- Extended by:
- Utilities::Helpers
- Defined in:
- lib/backup/compressor/gzip.rb
Defined Under Namespace
Classes: Error
Instance Attribute Summary collapse
-
#level ⇒ Object
Specify the level of compression to use.
-
#rsyncable ⇒ Object
Use the ‘–rsyncable` option with `gzip`.
Class Method Summary collapse
-
.has_rsyncable? ⇒ Boolean
Determine if
--rsyncable
is supported and cache the result.
Instance Method Summary collapse
-
#initialize(&block) ⇒ Gzip
constructor
Creates a new instance of Backup::Compressor::Gzip.
Methods inherited from Base
Methods included from Backup::Config::Helpers
Constructor Details
#initialize(&block) ⇒ Gzip
Creates a new instance of Backup::Compressor::Gzip
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/backup/compressor/gzip.rb', line 44 def initialize(&block) load_defaults! @level ||= false @rsyncable ||= false instance_eval(&block) if block_given? @cmd = "#{ utility(:gzip) }#{ }" @ext = '.gz' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers
Instance Attribute Details
#level ⇒ Object
Specify the level of compression to use.
Values should be a single digit from 1 to 9. Note that setting the level to either extreme may or may not give the desired result. Be sure to check the documentation for the compressor being used.
The default ‘level` is 6.
18 19 20 |
# File 'lib/backup/compressor/gzip.rb', line 18 def level @level end |
#rsyncable ⇒ Object
Use the ‘–rsyncable` option with `gzip`.
This option directs ‘gzip` to compress data using an algorithm that allows `rsync` to efficiently detect changes. This is especially useful when used to compress `Archive` or `Database` backups that will be stored using Backup’s ‘RSync` Storage option.
The ‘–rsyncable` option is only available on patched versions of `gzip`. While most distributions apply this patch, this option may not be available on your system. If it’s not available, Backup will log a warning and continue to use the compressor without this option.
32 33 34 |
# File 'lib/backup/compressor/gzip.rb', line 32 def rsyncable @rsyncable end |
Class Method Details
.has_rsyncable? ⇒ Boolean
Determine if --rsyncable
is supported and cache the result.
36 37 38 39 40 |
# File 'lib/backup/compressor/gzip.rb', line 36 def self.has_rsyncable? return @has_rsyncable unless @has_rsyncable.nil? cmd = "#{ utility(:gzip) } --rsyncable --version >/dev/null 2>&1; echo $?" @has_rsyncable = %x[#{ cmd }].chomp == '0' end |