Class: Backup::Syncer::RSync::Push
- Defined in:
- lib/backup/syncer/rsync/push.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#additional_ssh_options ⇒ Object
Additional SSH Options.
-
#compress ⇒ Object
Flag for compressing (only compresses for the transfer).
-
#host ⇒ Object
Server Address.
-
#mode ⇒ Object
Mode of operation.
-
#port ⇒ Object
SSH or RSync port.
-
#rsync_password ⇒ Object
RSync Password.
-
#rsync_password_file ⇒ Object
RSync Password File.
-
#rsync_user ⇒ Object
RSync User.
-
#ssh_user ⇒ Object
SSH User.
Attributes inherited from Base
Attributes inherited from Base
#excludes, #mirror, #path, #syncer_id
Instance Method Summary collapse
-
#initialize(syncer_id = nil) ⇒ Push
constructor
A new instance of Push.
- #perform! ⇒ Object
Methods inherited from Base
Methods included from Config::Helpers
Constructor Details
#initialize(syncer_id = nil) ⇒ Push
Returns a new instance of Push.
104 105 106 107 108 109 110 |
# File 'lib/backup/syncer/rsync/push.rb', line 104 def initialize(syncer_id = nil) super @mode ||= :ssh @port ||= mode == :rsync_daemon ? 873 : 22 @compress ||= false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers
Instance Attribute Details
#additional_ssh_options ⇒ Object
Additional SSH Options
Used to supply a String or Array of options to be passed to the SSH command in ‘:ssh` and `:ssh_daemon` modes.
For example, if you need to supply a specific SSH key for the ‘ssh_user`, you would set this to: “-i ’/path/to/id_rsa’”. Which would produce:
rsync -e "ssh -p 22 -i '/path/to/id_rsa'"
Arguments may be single-quoted, but should not contain any double-quotes.
Used only for ‘:ssh` and `:ssh_daemon` modes.
69 70 71 |
# File 'lib/backup/syncer/rsync/push.rb', line 69 def @additional_ssh_options end |
#compress ⇒ Object
Flag for compressing (only compresses for the transfer)
102 103 104 |
# File 'lib/backup/syncer/rsync/push.rb', line 102 def compress @compress end |
#host ⇒ Object
Server Address
28 29 30 |
# File 'lib/backup/syncer/rsync/push.rb', line 28 def host @host end |
#mode ⇒ Object
Mode of operation
- :ssh (default)
-
Connects to the remote via SSH. Does not use an rsync daemon on the remote.
- :ssh_daemon
-
Connects to the remote via SSH. Spawns a single-use daemon on the remote, which allows certain daemon features (like modules) to be used.
- :rsync_daemon
-
Connects directly to an rsync daemon via TCP. Data transferred is not encrypted.
24 25 26 |
# File 'lib/backup/syncer/rsync/push.rb', line 24 def mode @mode end |
#port ⇒ Object
SSH or RSync port
For ‘:ssh` or `:ssh_daemon` mode, this specifies the SSH port to use and defaults to 22.
For ‘:rsync_daemon` mode, this specifies the TCP port to use and defaults to 873.
38 39 40 |
# File 'lib/backup/syncer/rsync/push.rb', line 38 def port @port end |
#rsync_password ⇒ Object
RSync Password
If specified, Backup will write the password to a temporary file and use it with rsync’s ‘–password-file` option for daemon authentication.
Note that setting this will override ‘rsync_password_file`.
Used only for ‘:ssh_daemon` and `:rsync_daemon` modes.
89 90 91 |
# File 'lib/backup/syncer/rsync/push.rb', line 89 def rsync_password @rsync_password end |
#rsync_password_file ⇒ Object
RSync Password File
If specified, this path will be passed to rsync’s ‘–password-file` option for daemon authentication.
Used only for ‘:ssh_daemon` and `:rsync_daemon` modes.
98 99 100 |
# File 'lib/backup/syncer/rsync/push.rb', line 98 def rsync_password_file @rsync_password_file end |
#rsync_user ⇒ Object
RSync User
If the user running the backup is not the same user that needs to authenticate with the rsync daemon, specify the user here.
Used only for ‘:ssh_daemon` and `:rsync_daemon` modes.
78 79 80 |
# File 'lib/backup/syncer/rsync/push.rb', line 78 def rsync_user @rsync_user end |
#ssh_user ⇒ Object
SSH User
If the user running the backup is not the same user that needs to authenticate with the remote server, specify the user here.
The user must have SSH keys setup for passphrase-less access to the remote. If the SSH User does not have passphrase-less keys, or no default keys in their ‘~/.ssh` directory, you will need to use the `-i` option in `:additional_ssh_options` to specify the passphrase-less key to use.
Used only for ‘:ssh` and `:ssh_daemon` modes.
53 54 55 |
# File 'lib/backup/syncer/rsync/push.rb', line 53 def ssh_user @ssh_user end |
Instance Method Details
#perform! ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/backup/syncer/rsync/push.rb', line 112 def perform! log!(:started) write_password_file! create_dest_path! run("#{ rsync_command } #{ paths_to_push } " + "#{ }'#{ dest_path }'") log!(:finished) ensure remove_password_file! end |