Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: d1835cb960
Fetching contributors…

Cannot retrieve contributors at this time

executable file 40 lines (30 sloc) 1.115 kb
#!/usr/bin/env ruby
require 'yaml'
config = YAML.load_file('./config.yml')
date = Time.now.strftime("%Y-%m-%dT%H_%M_%S")
config['servers'].each do |server_name, server|
puts "=> Connecting to #{server_name}..."
if server["host"].empty? or server["host"].empty?
puts " => No host defined"
exit
end
host = ""
host = "#{server["user"]}@" if !server["user"].nil? and !server["user"].empty?
host += "#{server['host']}"
host += ":#{server['port']}" if !server["port"].nil? and !server["port"].empty?
# execute scripts
unless server["scripts"].nil?
server['scripts'].each do |script|
puts " => Executing script #{script}"
puts `ssh #{host} '#{script}'`
puts ""
end
end
dest = File.expand_path(server['destination'])
server['paths'].each do |path|
puts "=> Backing up #{path} to #{dest}"
puts `rsync -avv --progress --delete --link-dest=#{dest}/current #{host}:#{path} #{dest}/incomplete-#{date}`
end
puts `cd #{dest} && mv incomplete-#{date} #{date} && rm -f ./current && ln -s #{date} current`
puts "=> Done\n\n"
end
Jump to Line
Something went wrong with that request. Please try again.