from ftplib import FTP
import time,os,sys
print "按回車開始備份"
raw_input()
ftp=FTP()
ftp.set_debuglevel(2)
ftp.connect('服務器IP', '21')
ftp.login("用戶名","密碼")
ftp.cwd('/wwwroot/bbs/DataBase')
now = time.localtime()
blocksize = 1024
poststr = str(now.tm_year)+"-"+str(now.tm_mon)+"-"+str(now.tm_mday)
filename=r'e:\網站備份\bbs\database\Dbbs7'+poststr+'.asp'
if(os.path.isfile(filename)):
print "文件已經存在"
raw_input()
sys.exit()
file_handler = open(filename,'w').write
ftp.retrbinary("RETR Dbbs7.asp", file_handler, blocksize)
ftp.quit()
print "下載完畢"
raw_input()