class Backup::Syncer::RSync::Base

Attributes

additional_rsync_options[RW]

Additional String or Array of options for the rsync cli

archive[RW]

Public Class Methods

new(syncer_id = nil, &block) click to toggle source
Calls superclass method Backup::Syncer::Base::new
# File lib/backup/syncer/rsync/base.rb, line 13
def initialize(syncer_id = nil, &block)
  super
  instance_eval(&block) if block_given?

  @path ||= '~/backups'
  @archive = @archive.nil? ? true : @archive
end

Private Instance Methods

archive_option() click to toggle source
# File lib/backup/syncer/rsync/base.rb, line 34
def archive_option
  archive ? ' --archive' : ''
end
exclude_option() click to toggle source
# File lib/backup/syncer/rsync/base.rb, line 38
def exclude_option
  excludes.map {|pattern| " --exclude='#{ pattern }'" }.join
end
mirror_option() click to toggle source
# File lib/backup/syncer/rsync/base.rb, line 30
def mirror_option
  mirror ? ' --delete' : ''
end
paths_to_push() click to toggle source

Each path is expanded, since these refer to local paths and are being shell-quoted. This will also remove any trailing `/` from each path, as we don't want rsync's “trailing / on source directories” behavior. This method is used by RSync::Local and RSync::Push.

# File lib/backup/syncer/rsync/base.rb, line 47
def paths_to_push
  directories.map {|dir| "'#{ File.expand_path(dir) }'" }.join(' ')
end
rsync_command() click to toggle source

Common base command for Local/Push/Pull

# File lib/backup/syncer/rsync/base.rb, line 25
def rsync_command
  utility(:rsync) << archive_option << mirror_option << exclude_option <<
      " #{ Array(additional_rsync_options).join(' ') }".rstrip
end