lib/backup/storage/rsync.rb in backup-3.3.2 vs lib/backup/storage/rsync.rb in backup-3.4.0

- old
+ new

@@ -143,50 +143,44 @@ end private def transfer! - Logger.info "#{ storage_name } Started..." + write_password_file + create_remote_path - write_password_file! - create_dest_path! - - files_to_transfer_for(@package) do |local_file, remote_file| - src = "'#{ File.join(local_path, local_file) }'" - dest = "#{ host_options }'#{ File.join(dest_path, remote_file) }'" + package.filenames.each do |filename| + src = "'#{ File.join(Config.tmp_path, filename) }'" + dest = "#{ host_options }'#{ File.join(remote_path, filename) }'" Logger.info "Syncing to #{ dest }..." run("#{ rsync_command } #{ src } #{ dest }") end - - Logger.info "#{ storage_name } Finished!" ensure - remove_password_file! + remove_password_file end - ## # Storage::RSync doesn't cycle def cycle!; end ## - # Other storages use #remote_path_for to set the dest_path, - # which adds an additional timestamp directory to the path. + # Other storages add an additional timestamp directory to this path. # This is not desired here, since we need to transfer the package files # to the same location each time. # # Note: In v4.0, the additional trigger directory will to be dropped - # from dest_path for both local and :ssh mode, so the package files will - # be stored directly in #path. - def dest_path - @dest_path ||= begin + # from remote_path for both local and :ssh mode, so the package files + # will be stored directly in #path. + def remote_path + @remote_path ||= begin if host if mode == :ssh - File.join(path.sub(/^~\//, ''), @package.trigger) + File.join(path.sub(/^~\//, ''), package.trigger) else path.sub(/^~\//, '').sub(/\/$/, '') end else - File.join(File.expand_path(path), @package.trigger) + File.join(File.expand_path(path), package.trigger) end end end ## @@ -195,16 +189,16 @@ # file, and rsync won't attempt to create the intermediate directories. # # This is only applicable locally and in :ssh mode. # In :ssh_daemon and :rsync_daemon modes the `path` would include a # module name that must define a path on the remote that already exists. - def create_dest_path! + def create_remote_path if host run("#{ utility(:ssh) } #{ ssh_transport_args } #{ host } " + - %Q["mkdir -p '#{ dest_path }'"]) if mode == :ssh + %Q["mkdir -p '#{ remote_path }'"]) if mode == :ssh else - FileUtils.mkdir_p dest_path + FileUtils.mkdir_p(remote_path) end end def host_options @host_options ||= begin @@ -252,18 +246,18 @@ args << "-l #{ ssh_user } " if ssh_user args << Array(additional_ssh_options).join(' ') args.rstrip end - def write_password_file! + def write_password_file return unless host && rsync_password && mode != :ssh @password_file = Tempfile.new('backup-rsync-password') @password_file.write(rsync_password) @password_file.close end - def remove_password_file! + def remove_password_file @password_file.delete if @password_file end attr_deprecate :local, :version => '3.2.0', :message => "If 'host' is not set, the operation will be local."