Skip to content

Instantly share code, notes, and snippets.

@blasterpal
Created September 27, 2012 19:04
Show Gist options
  • Select an option

  • Save blasterpal/3795806 to your computer and use it in GitHub Desktop.

Select an option

Save blasterpal/3795806 to your computer and use it in GitHub Desktop.
Fetch a DB Backup from another server on EY
#!/usr/bin/ruby
if ARGV.size < 1
puts "you need to supply bucket"
exit
end
bucket = ARGV[1]
puts "fetching list of prod backups"
list = `sudo /usr/local/ey_resin/bin/eybackup -l BAM -e mysql -b #{bucket}`
puts list.split("\n")
latest_file = list.split('\n').first.split("\n").select{|ea| ea =~ /^[0-9]*:/}.last
latest_index = latest_file.split(":").first
puts "Downloading #{latest_file}"
`sudo /usr/local/ey_resin/bin/eybackup -e mysql -d #{latest_index}:BAM -b #{bucket}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment