Browse Source

Open FTP session on the last moment possible

Used to open  fp = open(file_path,'wb') a few lines before it was needed. This shouldn't be too much of a problem but opening and closing it right after eachother keeps the session open for less time and there are less chances on failure.
pull/203/head
Alessio Gerace 10 years ago
committed by archetipo
parent
commit
d7684d8413
  1. 2
      auto_backup/backup_scheduler.py

2
auto_backup/backup_scheduler.py

@ -152,7 +152,6 @@ password=passwordLogin,port=portHost)
#Create name for dumpfile.
bkp_file='%s_%s.dump' % (time.strftime('%d_%m_%Y_%H_%M_%S'),rec.name)
file_path = os.path.join(rec.bkp_dir,bkp_file)
fp = open(file_path,'wb')
uri = 'http://' + rec.host + ':' + rec.port
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/db')
bkp=''
@ -162,6 +161,7 @@ password=passwordLogin,port=portHost)
logger.notifyChannel('backup', netsvc.LOG_INFO, "Could'nt backup database %s. Bad database administrator password for server running at http://%s:%s" %(rec.name, rec.host, rec.port))
continue
bkp = base64.decodestring(bkp)
fp = open(file_path,'wb')
fp.write(bkp)
fp.close()
else:

Loading…
Cancel
Save