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

#directories, #mirror, #path

Instance Method Summary collapse

Methods inherited from Base

#add

Methods included from Configuration::Helpers

#clear_defaults!, #load_defaults!

Methods included from CLI::Helpers

#command_name, #raise_if_command_failed!, #run, #utility

Constructor Details

#initialize(&block) ⇒ Push

Instantiates a new RSync::Push or RSync::Pull Syncer object. Default configuration values and any specified in Backup::Configuration::Syncer::RSync:: are set from Base. The user’s configuration file is then evaluated to overwrite these values or provide additional configuration.



30
31
32
33
34
35
36
37
# File 'lib/backup/syncer/rsync/push.rb', line 30

def initialize(&block)
  super

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

  instance_eval(&block) if block_given?
end

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



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/backup/syncer/rsync/push.rb', line 42

def perform!
  write_password_file!

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

ensure
  remove_password_file!
end