Module: Backup::Utilities

Defined in:
lib/backup/utilities.rb

Defined Under Namespace

Modules: DSL, Helpers Classes: Error

Constant Summary collapse

UTILITY =
{}
NAMES =
%w{
  tar cat split sudo chown hostname
  gzip bzip2
  mongo mongodump mysqldump innobackupex
  pg_dump pg_dumpall redis-cli riak-admin
  gpg openssl
  rsync ssh
  sendmail exim
  send_nsca
  zabbix_sender
}

Class Method Summary collapse

Class Method Details

.configure(&block) ⇒ Object

Configure the path to system utilities used by Backup.

Backup will attempt to locate any required system utilities using a which command call. If a utility can not be found, or you need to specify an alternate path for a utility, you may do so in your config.rb file using this method.

Backup supports both GNU and BSD utilities. While Backup uses these utilities in a manner compatible with either version, the tar utility requires some special handling with respect to +Archive+s. Backup will attempt to detect if the tar command found (or set here) is GNU or BSD. If for some reason this fails, this may be set using the tar_dist command shown below.

Backup::Utilities.configure do
# General Utilites
tar      '/path/to/tar'
tar_dist :gnu   # or :bsd
cat      '/path/to/cat'
split    '/path/to/split'
sudo     '/path/to/sudo'
chown    '/path/to/chown'
hostname '/path/to/hostname'

# Compressors
gzip    '/path/to/gzip'
bzip2   '/path/to/bzip2'

# Database Utilities
mongo       '/path/to/mongo'
mongodump   '/path/to/mongodump'
mysqldump   '/path/to/mysqldump'
pg_dump     '/path/to/pg_dump'
pg_dumpall  '/path/to/pg_dumpall'
redis_cli   '/path/to/redis-cli'
riak_admin  '/path/to/riak-admin'

# Encryptors
gpg     '/path/to/gpg'
openssl '/path/to/openssl'

# Syncer and Storage
rsync   '/path/to/rsync'
ssh     '/path/to/ssh'

# Notifiers
sendmail  '/path/to/sendmail'
exim      '/path/to/exim'
send_nsca '/path/to/send_nsca'
zabbix_sender '/path/to/zabbix_sender'
end

These paths may be set using absolute paths, or relative to the working directory when Backup is run.



104
105
106
# File 'lib/backup/utilities.rb', line 104

def configure(&block)
  DSL.instance_eval(&block)
end

.gnu_tar?Boolean

Returns:

  • (Boolean)


113
114
115
116
# File 'lib/backup/utilities.rb', line 113

def gnu_tar?
  return @gnu_tar unless @gnu_tar.nil?
  @gnu_tar = !!run("#{ utility(:tar) } --version").match(/GNU/)
end

.tar_dist(val) ⇒ Object



108
109
110
111
# File 'lib/backup/utilities.rb', line 108

def tar_dist(val)
  # the acceptance tests need to be able to reset this to nil
  @gnu_tar = val.nil? ? nil : val == :gnu
end