#!/usr/bin/env python import commands, os, urllib, string, sys, time from elementtree import ElementTree as et # Connection info user = "reseller" passw = "pass" ip = "ip" # Get account list cmd = "curl -q --location-trusted -b /tmp/cpcookies.txt -c /tmp/cpcookies.txt -o /tmp/account_list.txt -u %s:%s 'http://%s:2086/xml-api/listaccts' > /dev/null 2>&1" %(user, passw, ip) os.system(cmd) # Get reseller's backup cmd = "curl --location-trusted -b /tmp/cpcookies.txt -c /tmp/cpcookies.txt -o /tmp/%s.tar.gz -u %s:%s http://%s:2082/getsysbackup/daily.tar.gz" %(user, user, passw, ip) os.system(cmd) # Parse account info li = [] f = open("/tmp/account_list.txt", "r") tree = et.parse(f) root = tree.getroot() for child in root.getchildren(): t = [] for i in range(len(child)): xmlData = child[i].text t.append("%s" %xmlData) li.append(t) for i in li: if len(i) == 0: pass else: u = i[-1] # switch session cmd = "curl --location-trusted -b /tmp/cpcookies.txt -c /tmp/cpcookies.txt -o /dev/null -u %s:%s http://%s:2082/xfercpanel/%s" %(user, passw, ip, u) os.system(cmd) # Get backup cmd = "curl --location-trusted -b /tmp/cpcookies.txt -c /tmp/cpcookies.txt -o /tmp/%s.tar.gz -u %s:%s http://%s:2082/getsysbackup/daily.tar.gz" %(u, user, passw, ip) os.system(cmd) print "Done getting backups." print