Created
July 24, 2012 02:26
-
-
Save fnando/3167622 to your computer and use it in GitHub Desktop.
Backup your DNSimple records
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
# 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