Skip to content

Instantly share code, notes, and snippets.

@azisaka
Created August 27, 2009 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save azisaka/176117 to your computer and use it in GitHub Desktop.
Save azisaka/176117 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'activesupport'
def rsync(directories, from, to, options = {})
options.reverse_merge!(:rsync => "-varRu",
:remote => true)
directories.each do |dir|
destination = options[:remote] ? "#{from}:/#{dir}" : "/#{dir}"
command = "rsync #{options[:rsync]} #{destination} #{to}"
puts command
system(command)
end
end
FROM = 'user@url.to-my.server'
DIRECTORIES = %w(home etc/nginx etc/haproxy)
TO = '/path/for/backup'
OPTIONS = { :rsync => '--progress -varRu' }
rsync DIRECTORIES, FROM, TO, OPTIONS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment