Sha256: 7c55bf90f501c2189e638455902bfcd186ff62266cd1625081a4d4a062d576da

Contents?: true

Size: 1.42 KB

Versions: 27

Compression:

Stored size: 1.42 KB

Contents

# encoding: utf-8

module Backup
  module Syncer
    module RSync
      class Base < Syncer::Base

        ##
        # Additional String or Array of options for the rsync cli
        attr_accessor :additional_rsync_options
        attr_accessor :archive

        def initialize(syncer_id = nil, &block)
          super
          instance_eval(&block) if block_given?

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

        private

        ##
        # Common base command for Local/Push/Pull
        def rsync_command
          utility(:rsync) << archive_option << mirror_option << exclude_option <<
              " #{ Array(additional_rsync_options).join(' ') }".rstrip
        end

        def mirror_option
          mirror ? ' --delete' : ''
        end

        def archive_option
          archive ? ' --archive' : ''
        end

        def exclude_option
          excludes.map {|pattern| " --exclude='#{ pattern }'" }.join
        end

        ##
        # 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.
        def paths_to_push
          directories.map {|dir| "'#{ File.expand_path(dir) }'" }.join(' ')
        end

      end
    end
  end
end

Version data entries

27 entries across 27 versions & 4 rubygems

Version Path
backup-ssh-4.4.5 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.19 lib/backup/syncer/rsync/base.rb
cm-backup-1.0.0 lib/backup/syncer/rsync/base.rb
backup-ssh-4.4.4 lib/backup/syncer/rsync/base.rb
backup-ssh-4.4.3 lib/backup/syncer/rsync/base.rb
backup-4.4.1 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.18 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.17 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.16 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.15 lib/backup/syncer/rsync/base.rb
backup-ssh-4.4.2 lib/backup/syncer/rsync/base.rb
backup-ssh-4.4.1 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.14 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.13 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.12 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.11 lib/backup/syncer/rsync/base.rb
backup-ssh-4.4.0 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.10 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.9 lib/backup/syncer/rsync/base.rb
backup-remote-0.0.8 lib/backup/syncer/rsync/base.rb