Created
March 29, 2016 16:08
-
-
Save gjedeer/4e3837ebb17b5d7db4ce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python | |
import os | |
import os.path | |
import ovh | |
import pprint | |
import shutil | |
client = ovh.Client() | |
backup_base = '/path/to/backup/zones/' | |
if not os.path.isdir(backup_base): | |
os.mkdir(backup_base) | |
domains = client.get("/domain/zone") | |
for domain in domains: | |
print domain | |
if '..' in domain: | |
print "WTF - double dot in domain name" | |
sys.exit(0) | |
backup_path = os.path.join(backup_base, domain) | |
export = client.get("/domain/zone/%s/export" % domain) | |
f = open(backup_path, "w+") | |
f.write(export) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment