Created
August 27, 2009 14:54
-
-
Save shadowmaru/176344 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = '[email protected]' | |
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