Skip to content

Instantly share code, notes, and snippets.

@lsmolic

lsmolic/gist:6084955

Created Jul 26, 2013
Embed
What would you like to do?
changes to asset auto_deploy
desc <<-DESC
Deploy the system directory to production
DESC
task :fs, :roles => :web, :once => true do
servers = find_servers_for_task(current_task)
puts "SERVERSSSSSSS......>>>>>>>> #{servers}"
servers.each do |server|
port = 22
Array(fetch(:sync_directories, [])).each do |syncdir|
destination, base = Pathname.new(syncdir).split
if File.directory? "#{syncdir}"
# 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 #{current_path}/#{syncdir}"
purge_old_backups "#{base}"
else
logger.info "Create '#{syncdir}' directory"
run "mkdir #{current_path}/#{syncdir}"
end
# Sync directory up
logger.info "sync #{syncdir} to #{server}:#{port} from local"
system "rsync --verbose --archive --compress --keep-dirlinks --delete --stats --rsh='ssh -p #{port}' #{syncdir}/* #{user}@#{server}:#{current_path}/#{syncdir}/"
end
logger.important "sync file system from local to the stage '#{stage}' finished"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment