Skip to content

Instantly share code, notes, and snippets.

/backup.rb Secret

Created December 4, 2013 17:25
Show Gist options
  • Save anonymous/068936196c72da518687 to your computer and use it in GitHub Desktop.
Save anonymous/068936196c72da518687 to your computer and use it in GitHub Desktop.
def backup
@time = Time.new
@Dtime = @time.strftime("%Y-%m-%d--%I:%M")
begin
Net::SSH.start("#{@host}", "#{@user}", :port =>"22", :password=>"#{@pwd}") do |ssh|
ssh.open_channel do |channel|
channel.on_request( "#{@mysl_dump} -u #{@mysql_user} -p'#{@mysql_password}' #{@uid_instance} |bzip2 > /data/# {@uid_instance}.#{@Dtime}.sql.bz2")
channel.process.popen3("#{@dump}") do | input, output, error|
input.puts @dump
puts "iiiii6>#{@dump}=#{output.read}"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment