Class: Backup::Syncer::RSync::Push

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/syncer/rsync/push.rb

Direct Known Subclasses

Pull

Constant Summary

Constants included from CLI::Helpers

CLI::Helpers::UTILITY

Instance Attribute Summary collapse

Attributes inherited from Base

#additional_options

Attributes inherited from Base

#mirror, #path

Instance Method Summary collapse

Methods inherited from Base

#add, #directories

Methods included from Configuration::Helpers

included

Constructor Details

#initialize(&block) ⇒ Push

Instantiates a new RSync::Push or RSync::Pull Syncer.

Pre-configured defaults specified in Configuration::Syncer::RSync::Push or Configuration::Syncer::RSync::Pull are set via a super() call to RSync::Base, which in turn will invoke Syncer::Base.

Once pre-configured defaults and RSync specific defaults are set, the block from the user’s configuration file is evaluated.



35
36
37
38
39
40
41
42
# File 'lib/backup/syncer/rsync/push.rb', line 35

def initialize(&block)
  super

  @port               ||= 22
  @compress           ||= false

  instance_eval(&block) if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Backup::Configuration::Helpers

Instance Attribute Details

#compressObject

Flag for compressing (only compresses for the transfer)



22
23
24
# File 'lib/backup/syncer/rsync/push.rb', line 22

def compress
  @compress
end

#ipObject

Server IP Address and SSH port



14
15
16
# File 'lib/backup/syncer/rsync/push.rb', line 14

def ip
  @ip
end

#passwordObject

Server credentials



10
11
12
# File 'lib/backup/syncer/rsync/push.rb', line 10

def password
  @password
end

#portObject

The SSH port to connect to



18
19
20
# File 'lib/backup/syncer/rsync/push.rb', line 18

def port
  @port
end

#usernameObject

Server credentials



10
11
12
# File 'lib/backup/syncer/rsync/push.rb', line 10

def username
  @username
end

Instance Method Details

#perform!Object

Performs the RSync:Push operation debug options: -vhP



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/backup/syncer/rsync/push.rb', line 47

def perform!
  write_password_file!

  Logger.message(
    "#{ syncer_name } started syncing the following directories:\n\s\s" +
    @directories.join("\n\s\s")
  )
  run("#{ utility(:rsync) } #{ options } #{ directories_option } " +
      "'#{ username }@#{ ip }:#{ dest_path }'")

ensure
  remove_password_file!
end