lib/capones_recipes/tasks/sync/fs.rb in capones_recipes-1.18.0 vs lib/capones_recipes/tasks/sync/fs.rb in capones_recipes-1.19.0
- old
+ new
@@ -40,25 +40,32 @@
set :stage, 'production' unless exists?(:stage)
server, port = host_and_port
Array(fetch(:sync_directories, [])).each do |syncdir|
destination, base = Pathname.new(syncdir).split
-
+
unless File.directory? "#{syncdir}"
logger.info "Create '#{syncdir}' directory"
run "mkdir -p #{shared_path}/#{syncdir}"
end
-
+
# Make a backup
logger.info "backup #{syncdir}"
run "tar cjf #{shared_path}/sync/#{base}.#{Time.now.strftime '%Y-%m-%d_%H:%M:%S'}.tar.bz2 #{shared_path}/#{syncdir}"
purge_old_backups "#{base}"
-
+
# Sync directory up
logger.info "sync #{syncdir} to #{server}:#{port} from local"
run_locally "rsync --verbose --archive --compress --keep-dirlinks --delete --stats --rsh='ssh -p #{port}' #{syncdir} #{user}@#{server}:#{shared_path}/#{destination.to_s}"
end
logger.important "sync filesystem from local to the stage '#{stage}' finished"
end
+ end
+
+ #
+ # Returns the actual host name to sync and port
+ #
+ def host_and_port
+ return roles[:web].servers.first.host, ssh_options[:port] || roles[:web].servers.first.port || 22
end
end
end