Class: Backup::Storage::RSync
- Includes:
- Utilities::Helpers
- Defined in:
- lib/backup/storage/rsync.rb
Instance Attribute Summary collapse
-
#additional_rsync_options ⇒ Object
Additional String or Array of options for the rsync cli.
-
#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.
-
#path ⇒ Object
Path to store the synced backup package file(s) to.
-
#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
#keep, #model, #package, #storage_id
Instance Method Summary collapse
-
#initialize(model, storage_id = nil) ⇒ RSync
constructor
A new instance of RSync.
Methods inherited from Base
Methods included from Config::Helpers
Constructor Details
#initialize(model, storage_id = nil) ⇒ RSync
Returns a new instance of RSync.
130 131 132 133 134 135 136 137 |
# File 'lib/backup/storage/rsync.rb', line 130 def initialize(model, storage_id = nil) super @mode ||= :ssh @port ||= mode == :rsync_daemon ? 873 : 22 @compress ||= false @path ||= '~/backups' end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Backup::Config::Helpers
Instance Attribute Details
#additional_rsync_options ⇒ Object
Additional String or Array of options for the rsync cli
104 105 106 |
# File 'lib/backup/storage/rsync.rb', line 104 def @additional_rsync_options end |
#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.
71 72 73 |
# File 'lib/backup/storage/rsync.rb', line 71 def @additional_ssh_options end |
#compress ⇒ Object
Flag for compressing (only compresses for the transfer)
108 109 110 |
# File 'lib/backup/storage/rsync.rb', line 108 def compress @compress end |
#host ⇒ Object
Server Address
If not specified, the storage operation will be local.
30 31 32 |
# File 'lib/backup/storage/rsync.rb', line 30 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/storage/rsync.rb', line 24 def mode @mode end |
#path ⇒ Object
Path to store the synced backup package file(s) to.
If no host
is specified, then path
will be local, and the only other used option would be additional_rsync_options
. path
will be expanded, so ‘~/my_path’ will expand to ‘$HOME/my_path’.
If a host
is specified, this will be a path on the host. If mode
is ‘:ssh` (default), then any relative path, or path starting with ’~/‘ will be relative to the directory the ssh_user is logged into. For `:ssh_daemon` or `:rsync_daemon` modes, this would reference an rsync module/path.
In :ssh_daemon and :rsync_daemon modes, path
(or path defined by your rsync module) must already exist.
In :ssh mode or local operation (no host
specified), path
will be created if needed - either locally, or on the remote for :ssh mode.
128 129 130 |
# File 'lib/backup/storage/rsync.rb', line 128 def path @path 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.
40 41 42 |
# File 'lib/backup/storage/rsync.rb', line 40 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.
91 92 93 |
# File 'lib/backup/storage/rsync.rb', line 91 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.
100 101 102 |
# File 'lib/backup/storage/rsync.rb', line 100 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.
80 81 82 |
# File 'lib/backup/storage/rsync.rb', line 80 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.
55 56 57 |
# File 'lib/backup/storage/rsync.rb', line 55 def ssh_user @ssh_user end |