Skip to content

Instantly share code, notes, and snippets.

@fnando
Created July 24, 2012 02:26
Show Gist options
  • Save fnando/3167622 to your computer and use it in GitHub Desktop.
Save fnando/3167622 to your computer and use it in GitHub Desktop.
Backup your DNSimple records
# gem install dnsimple-ruby
# $ <SPACE>PASSWORD="your password" EMAIL="your e-mail" ruby dnsimple_backup.rb > dnsimple_backup.yml
# when you put a space before running a command you prevent it from being added to the history.
require "dnsimple"
require "yaml"
DNSimple::Client.username = ENV.fetch("EMAIL")
DNSimple::Client.password = ENV.fetch("PASSWORD")
domains = {}
DNSimple::Domain.all.each do |domain|
domains[domain.name] ||= []
records = domains[domain.name]
DNSimple::Record.all(domain).each do |record|
records << {
:name => record.name,
:type => record.record_type,
:content => record.content,
:priority => record.prio,
:ttl => record.ttl
}
end
end
puts domains.to_yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment