Skip to content

Instantly share code, notes, and snippets.

@gjedeer
Created March 29, 2016 16:08
Show Gist options
  • Save gjedeer/4e3837ebb17b5d7db4ce to your computer and use it in GitHub Desktop.
Save gjedeer/4e3837ebb17b5d7db4ce to your computer and use it in GitHub Desktop.
#!/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