title: Download big files via FTP with python
body: <p>Im trying to download daily a backup file from my server to my local storage server, but i got some problems.</p>
  
  <p>I wrote this code (removed the useless parts, as the email function):</p>
  
  <pre><code>import os
  from time import strftime
  from ftplib import FTP
  import smtplib
  from email.MIMEMultipart import MIMEMultipart
  from email.MIMEBase import MIMEBase
  from email.MIMEText import MIMEText
  from email import Encoders
  
  day = strftime("%d")
  today = strftime("%d-%m-%Y")
  
  link = FTP(ftphost)
  link.login(passwd = ftp_pass, user = ftp_user)
  link.cwd(file_path)
  link.retrbinary('RETR ' + file_name, open('/var/backups/backup-%s.tgz' % today, 'wb').write)
  link.delete(file_name) #delete the file from online server
  link.close()
  mail(user_mail, "Download database %s" % today, "Database sucessfully downloaded: %s" % file_name)
  exit()
  </code></pre>
  
  <p>And i run this with a crontab like:</p>
  
  <pre><code>40    23    *    *    *    python /usr/bin/backup-transfer.py &gt;&gt; /var/log/backup-transfer.log 2&gt;&amp;1
  </code></pre>
  
  <p>It works with small files, but with the backups files (about 1.7Gb) it freeze, the downloaded file get about 1.2Gb then never grows up (i waited about a day), and the log file is empty.</p>
  
  <p>Any idea?</p>
  
  <p>p.s: im using Python 2.6.5</p>